/** * @param Form $form */ public function configure(Form $form) { $form->addGroup(); $langMode = $form->addSelect('langMode', 'Language mode', ElementEntity::getLangModes()); $langMode->addCondition($form::EQUAL, ElementEntity::LANGMODE_SPLIT)->toggle('form-group-language'); $form->setCurrentGroup($form->addGroup()->setOption('id', 'form-group-language')); $form->addManyToOne('language', 'Language')->addConditionOn($langMode, $form::EQUAL, ElementEntity::LANGMODE_SPLIT)->addRule($form::FILLED); $form->addGroup(); $mode = $form->addSelect('mode', 'Share data with', ElementEntity::getModes()); $mode->addCondition($form::IS_IN, array(1))->toggle('form-group-layout')->endCondition()->addCondition($form::IS_IN, array(2, 4))->toggle('form-group-page')->endCondition()->addCondition($form::EQUAL, 4)->toggle('form-group-route'); $form->addGroup()->setOption('id', 'form-group-layout'); $form->addManyToOne('layout', 'Layout')->addConditionOn($mode, $form::IS_IN, array(1))->addRule($form::FILLED); $form->addGroup()->setOption('id', 'form-group-page'); $page = $form->addManyToOne('page', 'Page'); $page->addConditionOn($mode, $form::IS_IN, array(2, 4))->addRule($form::FILLED); $form->addGroup()->setOption('id', 'form-group-route'); $form->addManyToOne('route', 'Route')->setDependOn($page, 'page')->addConditionOn($mode, $form::EQUAL, 4)->addRule($form::FILLED); $form->setCurrentGroup(); $form->addSaveButton('Save'); }
protected function createComponentElementTable() { $admin = new AdminGrid($this->elementRepository); // columns $table = $admin->getTable(); $table->setTranslator($this->translator); $table->addColumnText('nameRaw', 'Name')->setSortable()->setFilterText()->setSuggestion(); $table->getColumn('nameRaw')->getCellPrototype()->width = '23%'; $table->addColumnText('mode', 'Mode')->setSortable()->setCustomRender(function ($entity) { $modes = ElementEntity::getModes(); return $modes[$entity->mode]; })->getCellPrototype()->width = '12%'; $table->addColumnText('langMode', 'Language mode')->setSortable()->setCustomRender(function ($entity) { $modes = ElementEntity::getLangModes(); return $modes[$entity->langMode]; })->getCellPrototype()->width = '12%'; $table->addColumnText('page', 'Page')->setSortable()->getCellPrototype()->width = '20%'; $table->addColumnText('route', 'Route')->setSortable()->getCellPrototype()->width = '20%'; $table->addColumnText('language', 'Language')->setSortable()->getCellPrototype()->width = '15%'; // filters $table->addFilterSelect('mode', 'Mode', array('' => '') + ElementEntity::getModes()); $table->addFilterSelect('langMode', 'Mode', array('' => '') + ElementEntity::getLangModes()); // actions if ($this->isAuthorized('edit')) { $table->addAction('edit', 'Edit')->getElementPrototype()->class[] = 'ajax'; $form = $admin->createForm($this->basicFormFactory, 'Element'); $admin->connectFormWithAction($form, $table->getAction('edit')); } if ($this->isAuthorized('remove')) { $table->addAction('delete', 'Delete')->getElementPrototype()->class[] = 'ajax'; $admin->connectActionAsDelete($table->getAction('delete')); } $admin->onRender[] = function (AdminGrid $admin) { $qb = $admin->getRepository()->createQueryBuilder('a'); if (!$admin->parentFloor->floorId) { $qb = $qb->andWhere('a.layout IS NULL'); } else { $qb = $qb->andWhere('a.layout = :id')->setParameter('id', $admin->getParentFloor()->floorId); } $admin->getTable()->setModel(new Doctrine($qb)); }; return $admin; }