Exemplo n.º 1
0
 /**
  * Return linear array
  *
  * @param array $selected
  * @return array
  */
 protected function selectedArray(array $selected)
 {
     return \Engine\Tools\Arrays::assocToLinearArray($selected, $this->_name);
 }
Exemplo n.º 2
0
 /**
  * Render collection column type
  *
  * @param \Engine\Crud\Grid\Column $column
  * @return string
  */
 public static function _collection(Column\Collection $column)
 {
     $columnCode = [];
     $columnCode[] = "text: '" . $column->getTitle() . "'";
     $columnCode[] = "dataIndex: '" . $column->getKey() . "'";
     $columnCode[] = "width: " . $column->getWidth();
     if ($column->isSortable()) {
         $columnCode[] = "sortable: true";
     }
     if ($column->isHidden()) {
         $columnCode[] = "hidden: true";
     }
     if ($column->isEditable()) {
         $field = $column->getField();
         $options = \Engine\Tools\Arrays::assocToArray($field->getOptions());
         $columnCode[] = "field: {\n                    xtype: 'combobox',\n                    typeAhead: true,\n                    triggerAction: 'all',\n                    selectOnTab: true,\n                    store: " . json_encode($options) . ",\n                    lazyRender: true,\n                    listClass: 'x-combo-list-small'\n                }";
     }
     return forward_static_call(['static', '_implode'], $columnCode);
 }
Exemplo n.º 3
0
 /**
  * Return all reqeust params
  *
  * @return array
  */
 protected function _getParams()
 {
     $postParams = $this->request->getPost();
     $queryParams = $this->request->getQuery();
     $bodyParams = \Engine\Tools\Arrays::parse_str($this->request->getRawBody());
     return array_merge($queryParams, $postParams, $bodyParams);
 }
Exemplo n.º 4
0
 /**
  * @Route("/{crudModule:[a-z,-]+}/{crudGrid:[a-z,-]+}/{filterField:[a-z,-,_]+}/filter-options", methods={"GET"}, name="grid-options-json")
  */
 public function filterOptionsAction($module, $grid, $field)
 {
     $gridName = $this->_getGrid($module, $grid);
     $key = $grid;
     $grid = new $gridName([], $this->getDi(), $this->getEventsManager());
     $form = $grid->getFilter();
     $field = $form->getFieldByKey($field);
     if (!$field instanceof \Engine\Crud\Grid\Filter\Field\ArrayToSelect) {
         throw new \Engine\Exception("Field not instance of 'ArrayToSelect' field type");
     }
     $result = $field->getOptions();
     $result = \Engine\Tools\Arrays::assocToArray($result, 'id', 'name');
     echo json_encode([$key => $result]);
     $this->view->setRenderLevel(View::LEVEL_NO_RENDER);
 }