/** * @param Form $form */ protected function configure(Form $form) { $group = $form->addGroup('Registration'); $userTypes = array(); foreach ($this->securityManager->getUserTypes() as $name => $val) { $userTypes[$name] = $val->getName(); } $registrations = $form->addDynamic('registrations', function (Container $registration) use($form, $group, $userTypes) { $group = $form->addGroup('Registration'); $registration->setCurrentGroup($group); $registration->addCheckbox('enabled', 'Enabled')->addCondition($form::EQUAL, TRUE)->toggle('reg-' . $registration->name); $registration->setCurrentGroup($registration->form->addGroup()->setOption('id', 'reg-' . $registration->name)); $registration->addText('name', 'Name'); $registration->addSelect('userType', 'Type', $userTypes); $registration->addSelect('mode', 'Mode', PageEntity::getModes())->addCondition($form::IS_IN, array(PageEntity::MODE_MAIL, PageEntity::MODE_MAIL_CHECKUP))->toggle('email-' . $registration->name); $registration->addSelect('loginProviderMode', 'Login provider mode', PageEntity::getSocialModes()); $registration->addMultiSelect('roles', 'Roles', $this->getRoles()); $email = $registration->addContainer('email'); $email->setCurrentGroup($form->addGroup()->setOption('id', 'email-' . $registration->name)); $email->addText('subject', 'Subject'); $email->addText('sender', 'Sender'); $email->addText('from', 'From'); $email->addTextArea('text', 'Text'); $registration->addSubmit('_remove', 'Remove')->addRemoveOnClick(); }, 1); $registrations->setCurrentGroup($group); $registrations->addSubmit('_add', 'Add')->addCreateOnClick(); $form->setCurrentGroup(); $form->addSaveButton('Save'); }
/** * @param Form $form */ protected function configure(Form $form) { $toolbar = $form->addDynamic('toolbar', function (Container $container) use($form) { $group = $form->addGroup('Toolbar line'); $container->setCurrentGroup($group); $line = $container->addDynamic('line', function (Container $container) use($form, $group) { $container->setCurrentGroup($group); /** @var TagsInput $tags */ $tags = $container->addTags('items', 'Group'); $_this = $this; $tags->setSuggestCallback(function ($filters) use($_this) { return $_this->getToolbarItems($filters); }); $container->addSubmit('remove', 'Remove group')->addRemoveOnClick(); }); $line->addSubmit('add', 'Add group')->addCreateOnClick(); $container->addSubmit('remove', 'Remove line')->addRemoveOnClick(); }); $toolbar->addSubmit('add', 'Add line')->addCreateOnClick(); $form->setCurrentGroup(); $form->addSaveButton('Save'); }