/** * @param FormBuilderInterface $builder * @param array $options */ public function buildForm(FormBuilderInterface $builder, array $options) { $data = $builder->getData(); $builder->add('loginType', 'choice', ['choices' => $this->getAvailableTypes((string) $builder->getForm()->getPropertyPath()), 'expanded' => true, 'attr' => ['class' => 'btn-group', 'data-toggle' => 'buttons', 'data-login-type-toggle' => null], 'data' => $data && $data->getLoginType() ? $data->getLoginType() : Login::TYPE_NONE])->add('databaseName', null, ['attr' => ['data-login-type' => Login::TYPE_DB]])->add('username', null, ['attr' => ['data-login-type' => implode(' ', [Login::TYPE_SITE, Login::TYPE_SSH, Login::TYPE_DB])]])->add('password', null, ['attr' => ['data-login-type' => implode(' ', [Login::TYPE_SITE, Login::TYPE_SSH, Login::TYPE_DB])]])->add('sshKey', null, ['attr' => ['help-block' => 'The text of a PEM file used for login', 'data-login-type' => Login::TYPE_SSH]])->add('hostname', null, ['attr' => ['help-block' => 'DNS name for this login', 'data-login-type' => implode(' ', [Login::TYPE_SSH, Login::TYPE_DB])]])->add('port', null, ['attr' => ['data-login-type' => implode(' ', [Login::TYPE_SSH, Login::TYPE_DB])]])->add('url', null, ['attr' => ['data-login-type' => Login::TYPE_SITE]]); if ($this->includeProxy) { $builder->add('proxyHost', new LoginType(false), ['attr' => ['data-login-type' => Login::TYPE_DB]]); } }
/** * @param Request $request * @param string $type * @param array $data * @param array $options * @param ContainerInterface $container * @deprecated Thelia forms should not be instantiated directly. Please use BaseController::createForm() instead * @see BaseController::createForm() */ public function __construct(Request $request, $type = "form", $data = array(), $options = array(), ContainerInterface $container = null) { // Generate the form name from the complete class name $this->formUniqueIdentifier = strtolower(str_replace('\\', '_', get_class($this))); $this->request = $request; $this->type = $type; if (null !== $container) { $this->container = $container; $this->dispatcher = $container->get("event_dispatcher"); $this->initFormWithContainer($type, $data, $options); } else { $this->initFormWithRequest($type, $data, $options); } if (!isset($options["csrf_protection"]) || $options["csrf_protection"] !== false) { $this->formFactoryBuilder->addExtension(new CsrfExtension(new CsrfTokenManager(null, new SessionTokenStorage($this->getRequest()->getSession())))); } $this->formBuilder = $this->formFactoryBuilder->addExtension(new ValidatorExtension($this->validatorBuilder->getValidator()))->getFormFactory()->createNamedBuilder($this->getName(), $type, $data, $this->cleanOptions($options)); /** * Build the form */ $name = $this->getName(); $event = null; $dispatchEvents = $this->hasContainer() && $name !== null && $name !== ''; // We need to wrap the dispatch with a condition for backward compatibility if ($dispatchEvents) { $event = new TheliaFormEvent($this); /** * If the form has the container, disptach the events */ $this->dispatcher->dispatch(TheliaEvents::FORM_BEFORE_BUILD . "." . $name, $event); } $this->buildForm(); if ($dispatchEvents) { /** * If the form has the container, disptach the events */ $this->dispatcher->dispatch(TheliaEvents::FORM_AFTER_BUILD . "." . $name, $event); } // If not already set, define the success_url field // This field is not included in the standard form hidden fields // This field is not included in the hidden fields generated by form_hidden_fields Smarty function if (!$this->formBuilder->has('success_url')) { $this->formBuilder->add("success_url", "hidden"); } // If not already set, define the error_url field // This field is not included in the standard form hidden fields // This field is not included in the hidden fields generated by form_hidden_fields Smarty function if (!$this->formBuilder->has('error_url')) { $this->formBuilder->add("error_url", "hidden"); } // The "error_message" field defines the error message displayed if // the form could not be validated. If it is empty, a standard error message is displayed instead. // This field is not included in the hidden fields generated by form_hidden_fields Smarty function if (!$this->formBuilder->has('error_message')) { $this->formBuilder->add("error_message", "hidden"); } $this->form = $this->formBuilder->getForm(); }
public function buildForm(FormBuilderInterface $builder, array $options) { $builder->add('configItems', 'collection', array('type' => new ConfigType(), 'allow_add' => true, 'allow_delete' => true, 'by_reference' => false, 'label' => 'Clés de Configuration', 'options' => array('error_bubbling' => true, 'data_class' => 'AssoMaker\\PHPMBundle\\Entity\\Config'))); $builder->add('equipeItems', 'collection', array('type' => new EquipeType(), 'allow_add' => true, 'allow_delete' => true, 'by_reference' => false, 'label' => 'Équipes', 'options' => array('error_bubbling' => true, 'data_class' => 'AssoMaker\\BaseBundle\\Entity\\Equipe'))); $builder->add('registrationTokenItems', 'collection', array('type' => new RegistrationTokenType(), 'allow_add' => true, 'allow_delete' => true, 'by_reference' => false, 'label' => "Jetons d'inscription", 'options' => array('error_bubbling' => true, 'data_class' => 'AssoMaker\\BaseBundle\\Entity\\RegistrationToken'))); $builder->add('confianceItems', 'collection', array('type' => new ConfianceType(), 'allow_add' => true, 'allow_delete' => true, 'by_reference' => false, 'label' => 'Niveaux de Confiance', 'options' => array('error_bubbling' => true, 'data_class' => 'AssoMaker\\BaseBundle\\Entity\\Confiance'))); $builder->add('materielItems', 'collection', array('type' => new MaterielType(), 'allow_add' => true, 'allow_delete' => true, 'by_reference' => false, 'label' => 'Matériel', 'options' => array('error_bubbling' => true, 'data_class' => 'AssoMaker\\PHPMBundle\\Entity\\Materiel'))); $form = $builder->getForm(); }
public function createForm(FormBuilderInterface $formBuilder) { $formBuilder->setMethod('GET'); $formBuilder->add('status', ChoiceType::class, ['label' => 'Status', 'choices' => $this->translateStatus(AreaRequest::statusList()), 'required' => false]); $formBuilder->add('territory', ChoiceType::class, ['label' => 'Territory', 'choices' => $this->territoryRepository->getFormChoices(), 'required' => false]); $formBuilder->add('submit', SubmitType::class, ['label' => 'Filter']); $formBuilder->get('territory')->addModelTransformer(new EntityTransformer($this->territoryRepository)); return $formBuilder->getForm(); }
public function buildForm(FormBuilderInterface $builder, array $options) { $builder->add('name', 'text', array('trim' => true, 'label' => 'Nom de la chaine')); $builder->add('imageFile', FileType::class, array('trim' => true, 'label' => 'Illustration', 'attr' => array('class' => 'file', 'data-show-upload' => 'false'), 'required' => false)); $channel = $builder->getData(); if ($channel != null) { $form = $builder->getForm(); $form->get('imageFile')->setData($channel->getImageFile()); } }
public function buildForm(FormBuilderInterface $builder, array $options) { if (!$options['edit']) { $builder->add('username', 'text', ['label' => 'Nazwa użytkownika']); } if ($options['edit']) { $builder->add('oldPassword', 'password', ['label' => 'Obecne hasło', 'mapped' => false, 'required' => false, 'constraints' => [new UserPassword(['message' => 'Niepoprawne hasło.', 'groups' => ['change_password']])]]); } $builder->add('email')->add('newPassword', 'repeated', ['type' => 'password', 'invalid_message' => 'Hasła muszą być jednakowe', 'first_options' => ['label' => 'Hasło'], 'second_options' => ['label' => 'Powtórz hasło'], 'required' => !$options['edit'], 'mapped' => false])->add('firstName', 'text', ['label' => 'Imię'])->add('lastName', 'text', ['label' => 'Nazwisko'])->add('address', 'text', ['label' => 'Adres'])->add('address2', 'text', ['label' => 'Adres c. d.'])->add('zip', 'text', ['label' => 'Kod pocztowy'])->add('city', 'text', ['label' => 'Miasto'])->add('state', 'text', ['label' => 'Województwo'])->add('country', 'country', ['label' => 'Kraj', 'data' => $options['edit'] ? $builder->getForm()->getData()->getCountry() : 'PL']); }
/** * {@inheritdoc} */ public function buildForm(FormBuilderInterface $builder, array $options) { /** @var LineItem $formData */ $formData = $builder->getForm()->getData(); $product = $formData->getProduct(); $builder->add('quantity', 'text', ['required' => true, 'label' => 'orob2b.shoppinglist.lineitem.quantity.label'])->add('unit', ProductUnitSelectionType::NAME, ['required' => true, 'label' => 'orob2b.shoppinglist.lineitem.unit.label', 'query_builder' => function (ProductUnitRepository $repository) use($product) { return $repository->getProductUnitsQueryBuilder($product); }]); $builder->addEventSubscriber($this->lineItemSubscriber); }
public function buildForm(FormBuilderInterface $builder, array $options) { $choixDecalage = array(); for ($i = 1; $i <= 12; $i++) { $s = 3600 * $i; $choixDecalage[$s] = "{$i} h"; } for ($i = 1; $i <= 7; $i++) { $s = 24 * 3600 * $i; $choixDecalage[$s] = "{$i} j"; } $builder->add('disponibiliteInscriptionItems', 'entity', array('class' => 'AssoMakerPHPMBundle:DisponibiliteInscription', 'expanded' => true, 'multiple' => true, 'by_reference' => false, 'label' => 'Di'))->add('decalage', 'choice', array('label' => 'Avec un décalage de', 'choices' => $choixDecalage, 'empty_value' => 'Dupliquer et décaler', 'required' => false))->add('statut', 'choice', array('label' => 'Statut', 'empty_value' => 'Changer le statut', 'required' => false, 'choices' => array('0' => 'Verrouillé', '1' => 'Cochable Uniquement', '2' => 'Cochable/Décochable')))->add('mission', 'entity', array('class' => 'AssoMakerPHPMBundle:Mission', 'label' => 'Groupe', 'empty_value' => 'Changer la mission', 'required' => false))->add('pointsCharisme', null, array('label' => 'Points de Charisme', 'required' => false, 'attr' => array('placeHolder' => 'Changer les points de charisme')))->add('confiance', 'entity', array('class' => 'AssoMakerBaseBundle:Confiance', 'label' => 'Affecter les orgas', 'empty_value' => 'Affecter les orgas', 'required' => false))->add('confiance2', 'entity', array('class' => 'AssoMakerBaseBundle:Confiance', 'label' => 'Désaffecter les orgas', 'empty_value' => 'Désaffecter les orgas', 'required' => false)); $form = $builder->getForm(); }
/** * {@inheritdoc} */ public function buildForm(FormBuilderInterface $builder, array $options) { if ($builder->getForm()->getName() == CustomEntityType::NAME) { return; } $className = !empty($options['data_class']) ? $options['data_class'] : null; if (!$className) { return; } if (!$this->extendManager->getConfigProvider()->hasConfig($className)) { return; } if (!$this->hasActiveFields($className)) { return; } $builder->add('additional', CustomEntityType::NAME, array('inherit_data' => true, 'class_name' => $className)); }
/** * Render a form and return the HTML. */ private function renderForm(FormBuilderInterface $formBuilder) { $formView = $formBuilder->getForm()->createView(); $templating = $this->getContainer()->get('templating'); return $templating->render('::form.html.twig', array('form' => $formView)); }
/** * @param HandlerInterface[]|array $requestHandlers * @param \Symfony\Component\Form\FormBuilderInterface $formBuilder */ public function __construct(array $requestHandlers, FormBuilderInterface $formBuilder) { parent::__construct($requestHandlers); $this->form = $formBuilder->getForm(); }
/** * @param FormBuilderInterface $builder * @param array $options */ public function buildForm(FormBuilderInterface $builder, array $options) { $instrument = $builder->getForm()->getData(); $builder->add('name')->add('newPrice')->add('price')->add('description')->add('features')->add('vendor', 'entity', array('class' => 'AppBundle\\Entity\\Vendor'))->add('category', 'entity', array('class' => 'AppBundle\\Entity\\Category'))->add('gallery', 'comur_gallery', array('uploadConfig' => array('uploadRoute' => 'comur_api_upload', 'uploadUrl' => $instrument->getUploadRootDir(), 'webDir' => $instrument->getUploadDir(), 'fileExt' => '*.jpg;*.gif;*.png;*.jpeg', 'libraryDir' => null, 'libraryRoute' => 'comur_api_image_library', 'showLibrary' => true), 'cropConfig' => array('minWidth' => 500, 'minHeight' => 500, 'aspectRatio' => true, 'cropRoute' => 'comur_api_crop', 'forceResize' => false, 'thumbs' => array(array('maxWidth' => 400, 'maxHeight' => 400, 'useAsFieldImage' => true))))); }
/** * Builds the form. * * @param \Sonata\AdminBundle\Util\AdminObjectAclData $data * @param \Symfony\Component\Form\FormBuilderInterface $formBuilder * @param \Traversable $aclValues * * @return \Symfony\Component\Form\Form */ protected function buildForm(AdminObjectAclData $data, FormBuilderInterface $formBuilder, \Traversable $aclValues) { // Retrieve object identity $objectIdentity = ObjectIdentity::fromDomainObject($data->getObject()); $acl = $data->getSecurityHandler()->getObjectAcl($objectIdentity); if (!$acl) { $acl = $data->getSecurityHandler()->createAcl($objectIdentity); } $data->setAcl($acl); $masks = $data->getMasks(); $securityInformation = $data->getSecurityInformation(); foreach ($aclValues as $key => $aclValue) { $securityIdentity = $this->getSecurityIdentity($aclValue); $permissions = array(); foreach ($data->getUserPermissions() as $permission) { try { $checked = $acl->isGranted(array($masks[$permission]), array($securityIdentity)); } catch (NoAceFoundException $e) { $checked = false; } $attr = array(); if (self::ACL_ROLES_FORM_NAME === $formBuilder->getName() && isset($securityInformation[$aclValue]) && array_search($permission, $securityInformation[$aclValue]) !== false) { $attr['disabled'] = 'disabled'; } $permissions[$permission] = array('required' => false, 'data' => $checked, 'disabled' => array_key_exists('disabled', $attr), 'attr' => $attr); } $formBuilder->add($key, new AclMatrixType(), array('permissions' => $permissions, 'acl_value' => $aclValue)); } return $formBuilder->getForm(); }
/** * @param FormBuilderInterface $builder * @param array $options */ public function buildForm(FormBuilderInterface $builder, array $options) { $media = $builder->getForm()->getData(); $builder->add('image', 'comur_image', array('uploadConfig' => array('uploadRoute' => 'comur_api_upload', 'uploadUrl' => $media->getUploadRootDir(), 'webDir' => $media->getUploadDir(), 'fileExt' => '*.jpg;*.gif;*.png;*.jpeg', 'libraryDir' => null, 'libraryRoute' => 'comur_api_image_library', 'showLibrary' => false), 'cropConfig' => array('minWidth' => 400, 'minHeight' => 400, 'aspectRatio' => true, 'cropRoute' => 'comur_api_crop', 'forceResize' => false, 'thumbs' => array(array('maxWidth' => 400, 'maxHeight' => 400, 'useAsFieldImage' => false))))); }
/** * {@inheritdoc} */ public function buildPager() { if ($this->bound) { return; } foreach ($this->getFilters() as $name => $filter) { list($type, $options) = $filter->getRenderSettings(); $this->formBuilder->add($filter->getFormName(), $type, $options); } $this->formBuilder->add('_sort_by', 'hidden'); $this->formBuilder->get('_sort_by')->addViewTransformer(new CallbackTransformer(function ($value) { return $value; }, function ($value) { return $value instanceof FieldDescriptionInterface ? $value->getName() : $value; })); $this->formBuilder->add('_sort_order', 'hidden'); $this->formBuilder->add('_page', 'hidden'); $this->formBuilder->add('_per_page', 'hidden'); $this->form = $this->formBuilder->getForm(); $this->form->submit($this->values); $data = $this->form->getData(); foreach ($this->getFilters() as $name => $filter) { $this->values[$name] = isset($this->values[$name]) ? $this->values[$name] : null; $filter->apply($this->query, $data[$filter->getFormName()]); } if (isset($this->values['_sort_by'])) { if (!$this->values['_sort_by'] instanceof FieldDescriptionInterface) { throw new UnexpectedTypeException($this->values['_sort_by'], 'FieldDescriptionInterface'); } if ($this->values['_sort_by']->isSortable()) { $this->query->setSortBy($this->values['_sort_by']->getSortParentAssociationMapping(), $this->values['_sort_by']->getSortFieldMapping()); $this->query->setSortOrder(isset($this->values['_sort_order']) ? $this->values['_sort_order'] : null); } } $maxPerPage = 25; if (isset($this->values['_per_page'])) { // check for `is_array` can be safely removed if php 5.3 support will be dropped if (is_array($this->values['_per_page'])) { if (isset($this->values['_per_page']['value'])) { $maxPerPage = $this->values['_per_page']['value']; } } else { $maxPerPage = $this->values['_per_page']; } } $this->pager->setMaxPerPage($maxPerPage); $page = 1; if (isset($this->values['_page'])) { // check for `is_array` can be safely removed if php 5.3 support will be dropped if (is_array($this->values['_page'])) { if (isset($this->values['_page']['value'])) { $page = $this->values['_page']['value']; } } else { $page = $this->values['_page']; } } $this->pager->setPage($page); $this->pager->setQuery($this->query); $this->pager->init(); $this->bound = true; }
public function buildHeaderView(ColumnTypeInterface $column, HeaderViewInterface $view) { $this->buildBatchForm($column, $this->buildBatchActions($column)); $view->setAttribute('batch_form', $this->formBuilder->getForm()->createView()); }
/** * {@inheritdoc} */ public function buildForm(FormBuilderInterface $builder, array $options) { $validator = new CaptchaValidator($this->translator, $this->session, sprintf('gcb_%s', $builder->getForm()->getName()), $options['invalid_message'], $options['bypass_code'], $options['humanity']); $event = \Symfony\Component\HttpKernel\Kernel::VERSION >= 2.3 ? FormEvents::POST_SUBMIT : FormEvents::POST_BIND; $builder->addEventListener($event, array($validator, 'validate')); }
/** * @return \Symfony\Component\Form\Form */ public function getForm() { return $this->formBuilder->getForm(); }
public function createForm(FormBuilderInterface $formBuilder) { $formBuilder->setMethod('GET'); $formBuilder->add('status', ChoiceType::class, ['label' => 'Status', 'choices' => $this->statusRepository->getFormChoices(), 'required' => false]); if (!$this->fixedGroup) { $formBuilder->add('group', ChoiceType::class, ['label' => 'Group', 'choices' => $this->groupRepository->getFormChoices(), 'required' => false]); $formBuilder->add('category', ChoiceType::class, ['label' => 'Category', 'choices' => $this->categoryRepository->getFormChoices(), 'required' => false]); } $formBuilder->add('territory', ChoiceType::class, ['label' => 'Territory', 'choices' => $this->territoryRepository->getFormChoices(), 'required' => false]); $formBuilder->add('submit', SubmitType::class, ['label' => 'Filter']); $formBuilder->get('status')->addModelTransformer(new EntityTransformer($this->statusRepository)); if (!$this->fixedGroup) { $formBuilder->get('group')->addModelTransformer(new EntityTransformer($this->groupRepository)); $formBuilder->get('category')->addModelTransformer(new EntityTransformer($this->categoryRepository)); } $formBuilder->get('territory')->addModelTransformer(new EntityTransformer($this->territoryRepository)); return $formBuilder->getForm(); }
/** * {@inheritdoc} */ public function buildForm(FormBuilderInterface $builder, array $options) { $tagitOptions = $this->getTagitOptions($builder->getForm()); $builder->addModelTransformer(new TagsTransformer($this->taggableManager, $tagitOptions['singleFieldDelimiter'])); }
/** * @param \Symfony\Component\Form\FormBuilderInterface $builder * @param array $options */ public function buildForm(FormBuilderInterface $builder, array $options) { $validator = new CaptchaValidator($this->translator, $this->session, sprintf('gcb_%s', $builder->getForm()->getName()), $options['invalid_message'], $options['bypass_code'], $options['humanity']); $builder->addEventListener(FormEvents::POST_BIND, array($validator, 'validate')); }
/** * @param FormBuilderInterface $builder * @param array $options */ public function buildForm(FormBuilderInterface $builder, array $options) { $teamMember = $builder->getForm()->getData(); $builder->add('name')->add('description')->add('teamGroup', 'entity', array('class' => 'AppBundle\\Entity\\TeamGroup'))->add('image', 'comur_image', array('uploadConfig' => array('uploadRoute' => 'comur_api_upload', 'uploadUrl' => $teamMember->getUploadRootDir(), 'webDir' => $teamMember->getUploadDir(), 'fileExt' => '*.jpg;*.gif;*.png;*.jpeg', 'libraryDir' => null, 'libraryRoute' => 'comur_api_image_library', 'showLibrary' => true, 'saveOriginal' => 'originalImage'), 'cropConfig' => array('minWidth' => 500, 'minHeight' => 500, 'aspectRatio' => true, 'cropRoute' => 'comur_api_crop', 'forceResize' => false, 'thumbs' => array(array('maxWidth' => 400, 'maxHeight' => 400, 'useAsFieldImage' => true))))); }
public function buildForm(FormBuilderInterface $builder, array $options) { $this->key = $builder->getForm()->getName(); $builder->addValidator(new CaptchaValidator($this->session, $this->key, $options['invalid_message'], $options['bypass_code'])); }
/** * @param FormBuilderInterface $builder * @param array $options */ public function buildForm(FormBuilderInterface $builder, array $options) { $myEntity = $builder->getForm()->getData(); $builder->add('title')->add('imgFile', 'file', array('required' => false))->add('imgFileMedium', 'file', array('required' => false))->add('content')->add('tags')->add('valid')->add('address')->add('zip')->add('city')->add('country', 'entity', array('required' => true, 'class' => 'Event\\Bundle\\Entity\\Country'))->add('dateEvent', 'date', array('required' => true, 'format' => 'yyyy-MM-dd', 'widget' => 'single_text'))->add('dateEventFin', 'date', array('required' => true, 'format' => 'yyyy-MM-dd', 'widget' => 'single_text'))->add('url')->add('email')->add('phone')->add('specialite')->add('cible')->add('client')->add('type', 'entity', array('required' => true, 'class' => 'Event\\Bundle\\Entity\\Type')); }