示例#1
0
 /**
  * {@inheritdoc}
  */
 public function buildForm(FormBuilderInterface $builder, array $options)
 {
     $builder->addEventSubscriber(new AddCodeFormSubscriber())->addEventSubscriber(new BuildReportDataFetcherFormSubscriber($this->dataFetcherRegistry, $builder->getFormFactory()))->addEventSubscriber(new BuildReportRendererFormSubscriber($this->rendererRegistry, $builder->getFormFactory()))->add('name', 'text', ['label' => 'sylius.form.report.name', 'required' => true])->add('description', 'textarea', ['label' => 'sylius.form.report.description', 'required' => false])->add('dataFetcher', 'sylius_data_fetcher_choice', ['label' => 'sylius.form.report.data_fetcher'])->add('renderer', 'sylius_renderer_choice', ['label' => 'sylius.form.report.renderer.label']);
     $prototypes = ['renderers' => [], 'dataFetchers' => []];
     foreach ($this->rendererRegistry->all() as $type => $renderer) {
         $formType = sprintf('sylius_renderer_%s', $renderer->getType());
         if (!$formType) {
             continue;
         }
         try {
             $prototypes['renderers'][$type] = $builder->create('rendererConfiguration', $formType)->getForm();
         } catch (\InvalidArgumentException $e) {
             continue;
         }
     }
     foreach ($this->dataFetcherRegistry->all() as $type => $dataFetcher) {
         $formType = sprintf('sylius_data_fetcher_%s', $dataFetcher->getType());
         if (!$formType) {
             continue;
         }
         try {
             $prototypes['dataFetchers'][$type] = $builder->create('dataFetcherConfiguration', $formType)->getForm();
         } catch (\InvalidArgumentException $e) {
             continue;
         }
     }
     $builder->setAttribute('prototypes', $prototypes);
 }
示例#2
0
 /**
  * {@inheritDoc}
  */
 public function buildForm(FormBuilderInterface $formBuilder, array $options)
 {
     $subscriber = new AddIdFieldSubscriber($formBuilder->getFormFactory());
     $formBuilder->addEventSubscriber($subscriber);
     $subscriber = new AddContentTypeFieldSubscriber($formBuilder->getFormFactory(), $this->mediasizes);
     $formBuilder->addEventSubscriber($subscriber);
     $contentTypeChoices = $this->contentTypes;
     reset($contentTypeChoices);
     $prefContentTypeChoice = key($contentTypeChoices);
     $sizeclassChoices = $this->contentsizes;
     reset($sizeclassChoices);
     $prefSizeclassChoice = key($sizeclassChoices);
     $formBuilder->add('title', 'text', array('label' => 'Content Block Title', 'required' => true))->add('publishedState', 'choice', array('choices' => array('0' => 'Unpublished', '1' => 'Published'), 'preferred_choices' => array('1'), 'label' => 'Publish State', 'required' => true))->add('availability', 'choice', array('choices' => array('page' => 'Page Only', 'global' => 'Global'), 'preferred_choices' => array('0'), 'label' => 'Available to', 'required' => true))->add('showTitle', 'choice', array('choices' => array('0' => 'Hide Title', '1' => 'Show Title'), 'preferred_choices' => array('1'), 'label' => 'Title Display State', 'required' => true))->add('ordering', 'hidden', array('attr' => array('class' => 'orderField'), 'label' => 'Content Block Ordering', 'required' => true))->add('className', 'text', array('label' => 'CSS Class', 'required' => false))->add('idName', 'text', array('label' => 'CSS Id', 'required' => false))->add('sizeClass', 'choice', array('choices' => $sizeclassChoices, 'preferred_choices' => array($prefContentTypeChoice), 'label' => 'Content Block Width', 'required' => true))->add('contentType', 'choice', array('choices' => $contentTypeChoices, 'preferred_choices' => array($prefSizeclassChoice), 'label' => 'Content Type', 'required' => true));
 }
示例#3
0
 /**
  * @param FormBuilderInterface $builder
  * @param array $options
  */
 public function buildForm(FormBuilderInterface $builder, array $options)
 {
     $customerId = $options['customerId'];
     $builder->add('name')->add('code')->add('file', 'file', array("required" => false))->add('sucursales', 'entity', array('class' => 'BackendCustomerAdminBundle:Sucursal', 'query_builder' => function (EntityRepository $er) use($customerId) {
         return $er->createQueryBuilder('u')->where('u.customer = ' . $customerId)->orderBy('u.name', 'ASC');
     }, 'multiple' => true, 'mapped' => true, 'required' => true))->add('precio')->add('alwaysAvailable')->add('maxVariedad')->add('minVariedad')->add('qtyVariedad', 'checkbox', array('value' => 1, 'required' => false))->add('isActive', 'checkbox', array('value' => 1, 'required' => false))->add('file', 'file', array("required" => false))->add('description');
     //deben ser las variedades del producto que ya esten cargadas previamente para el mismo customer
     $builder->add('variedades', 'entity', array('class' => 'BackendCustomerAdminBundle:Variedad', 'query_builder' => function (EntityRepository $er) use($customerId) {
         return $er->createQueryBuilder('u')->where('u.customer = ' . $customerId)->orderBy('u.name', 'ASC');
     }, 'multiple' => true, 'mapped' => true, 'required' => true));
     $categoriaSubscriber = new CategoriaSubscriber($builder->getFormFactory());
     $builder->addEventSubscriber($categoriaSubscriber);
     $subcategoriaSubscriber = new SubcategoriaSubscriber($builder->getFormFactory());
     $builder->addEventSubscriber($subcategoriaSubscriber);
 }
示例#4
0
 public function buildForm(FormBuilderInterface $builder, array $options)
 {
     $subscriber = new ReplaceNotSubmittedValuesByDefaultsListener($builder->getFormFactory());
     $builder->addEventSubscriber($subscriber);
     $builder->add('page', 'hidden', array('required' => false, 'attr' => array('id' => 'page')));
     $builder->add('limit', 'hidden', array('required' => false, 'attr' => array('id' => 'limit')));
 }
示例#5
0
 /**
  * @param FormBuilderInterface $builder
  * @param array $options
  */
 public function buildForm(FormBuilderInterface $builder, array $options)
 {
     // ajout de action si défini
     if (isset($this->parametres['form_action'])) {
         $builder->setAction($this->parametres['form_action']);
     }
     // Builder…
     $factory = $builder->getFormFactory();
     $builder->addEventListener(FormEvents::PRE_SET_DATA, function (FormEvent $event) use($factory) {
         $data = $event->getData();
         // important : GARDER CETTE CONDITION CI-DESSOUS (toujours !!!)
         if (null === $data) {
             return;
         }
         if (null === $data->getId()) {
             // création
             $event->getForm()->add('nom', 'textarea', array('label' => 'form.nom', 'required' => true, 'attr' => array('rows' => 6, 'style' => 'resize: vertical;')));
         } else {
             // L'entité existe : édition
             $event->getForm()->add('nom', 'text', array('label' => 'form.nom', 'required' => true));
         }
     });
     // ajoute les valeurs hidden, passés en paramètre
     $builder = $this->addHiddenValues($builder);
     // AJOUT SUBMIT
     $builder->add('submit', 'submit', array('label' => 'form.enregistrer', 'attr' => array('class' => "btn btn-md btn-block btn-info")));
 }
示例#6
0
 /**
  * @param FormBuilderInterface $builder
  * @param array $options
  */
 public function buildForm(FormBuilderInterface $builder, array $options)
 {
     $builder->add('date', 'date')->add('titre', 'text')->add('auteur', 'text')->add('contenu', 'textarea')->add('image', new ImageType())->add('categories', 'collection', array('type' => new CategorieType(), 'allow_add' => true, 'allow_delete' => true))->add('categories', 'entity', array('class' => 'SdzBlogBundle:Categorie', 'property' => 'nom', 'multiple' => true, 'expanded' => false));
     $factory = $builder->getFormFactory();
     // on ajoute une fonction qui permet d'écouter l'evenement
     $builder->addEventListener(FormEvents::PRE_SET_DATA, function (FormEvent $event) use($factory) {
         // on définit une fct qui seras exécuté lors de l'evenement
         $article = $event->getData();
         //dump($article);de;
         $publi = $article->getPublication();
         if (null === $article) {
             return;
             // on sort de la fonction lorque $article vaut null
         }
         //si l'article n'est pas encore publié c est adire que $publi=== null  ou égale false c est adire
         // n'a pas encoré été coché, on
         // ajoute le champ de
         // publication
         if ($publi === null || $publi === false) {
             $event->getForm()->add($factory->createNamed('publication', 'checkbox', null, array('required' => false, 'auto_initialize' => false)));
         } else {
             // sinon on le supprime
             $event->getForm()->remove('publication');
         }
     });
 }
示例#7
0
 /**
  * {@inheritDoc}
  */
 public function buildForm(FormBuilderInterface $builder, array $options)
 {
     $tokenStorage = $options['token_storage'];
     $builder->add('dni')->add('address')->add('city')->add('state', EntityType::class, array('class' => 'CoreBundle:State', 'query_builder' => function (EntityRepository $er) {
         return $er->createQueryBuilder('c');
     }, 'required' => false, 'placeholder' => 'Selecciona tu provincia'))->add('country', EntityType::class, array('class' => 'CoreBundle:Country', 'query_builder' => function (EntityRepository $er) {
         return $er->createQueryBuilder('c');
     }, 'required' => false, 'placeholder' => 'Selecciona tu país'))->add('postalCode')->add('phone')->add('phone2')->add('preferredSchedule', ChoiceType::class, array('choices' => Address::getSchedules(), 'required' => false, 'choices_as_values' => true));
     $user = $tokenStorage->getToken()->getUser();
     if (!$user) {
         throw new \LogicException('The AddressFormType cannot be used without an authenticated user!');
     }
     $factory = $builder->getFormFactory();
     $builder->addEventListener(FormEvents::PRE_SET_DATA, function (FormEvent $event) use($user, $factory) {
         $form = $event->getForm();
         // if user is a business, add the contact person field
         //            if ($user::BUSINESS == $user->getAccountType()) {
         //                $formOptions = array(
         //                    'required' => false
         //                );
         //
         //                $form->add($factory->createNamed('contactPerson', 'text', null, $formOptions));
         //            }
     });
 }
 /**
  * {@inheritDoc}
  */
 public function buildForm(FormBuilderInterface $builder, array $options)
 {
     $conversation = $this->conversationContext->getConversation();
     if ($conversation !== null) {
         $builder->setAttribute('conversation_factory', $builder->getFormFactory());
     }
 }
 /**
  * @param FormBuilderInterface $builder
  * @param array $options
  */
 public function buildForm(FormBuilderInterface $builder, array $options)
 {
     $builder->add('venue', 'text', ['label' => 'admin.registration_event.field.venue'])->add('address', 'text', ['label' => 'admin.registration_event.field.address'])->add('country', 'entity', ['label' => 'admin.registration_event.field.country', 'class' => 'AppBundle\\Entity\\Country', 'property' => 'name', 'required' => true, 'empty_value' => 'admin.form.select_empty_value', 'query_builder' => function ($repository) {
         return $repository->createQueryBuilder('c')->add('orderBy', 's.name ASC');
     }])->add('postalCode', 'text', ['label' => 'admin.registration_event.field.postal_code'])->add('date', 'date', ['label' => 'admin.registration_event.field.date', 'widget' => 'single_text'])->add('domain', 'choice', ['label' => 'admin.registration_event.field.domain', 'choices' => $this->domains])->add('time_groups', 'collection', ['label' => 'admin.registration_event.field.time_groups', 'type' => 'admin_time_group', 'allow_add' => true, 'allow_delete' => true, 'by_reference' => false]);
     $factory = $builder->getFormFactory();
     $refreshStates = function ($form, $country) use($factory) {
         $stateAttr = $country ? [] : ['disabled' => 'disabled'];
         $form->add($factory->createNamed('state', 'entity', null, ['label' => 'admin.registration_event.field.state', 'class' => 'AppBundle\\Entity\\State', 'property' => 'name', 'required' => true, 'empty_value' => 'admin.form.select_empty_value', 'auto_initialize' => false, 'attr' => $stateAttr, 'query_builder' => function (StateRepository $repository) use($country) {
             return $repository->createQueryBuilder('s')->add('orderBy', 's.name ASC')->add('where', 's.country = :country')->setParameter('country', $country);
         }]));
     };
     $refreshCities = function ($form, $state) use($factory) {
         $cityAttr = $state ? [] : ['disabled' => 'disabled'];
         $form->add($factory->createNamed('city', 'entity', null, ['label' => 'admin.registration_event.field.city', 'class' => 'AppBundle\\Entity\\City', 'property' => 'name', 'required' => true, 'empty_value' => 'admin.form.select_empty_value', 'auto_initialize' => false, 'attr' => $cityAttr, 'query_builder' => function (CityRepository $repository) use($state) {
             return $repository->createQueryBuilder('cT')->add('orderBy', 'cT.name ASC')->add('where', 'cT.state = :state')->setParameter('state', $state);
         }]));
     };
     $builder->addEventListener(FormEvents::PRE_SET_DATA, function (FormEvent $event) use($refreshStates, $refreshCities) {
         $form = $event->getForm();
         $data = $event->getData();
         if ($data instanceof RegistrationEvent) {
             $refreshStates($form, $data->getId() ? $data->getCountry() : null);
             $refreshCities($form, $data->getId() ? $data->getState() : null);
         }
     });
     $builder->addEventListener(FormEvents::PRE_SUBMIT, function (FormEvent $event) use($refreshStates, $refreshCities) {
         $form = $event->getForm();
         $data = $event->getData();
         $refreshStates($form, array_key_exists('country', $data) ? $data['country'] : null);
         $refreshCities($form, array_key_exists('state', $data) ? $data['state'] : null);
     });
 }
 public function buildForm(FormBuilderInterface $builder, array $options)
 {
     if (!$options['honeypot']) {
         return;
     }
     $builder->setAttribute('honeypot_factory', $builder->getFormFactory())->addEventSubscriber(new HoneypotValidationListener($this->translator, $this->translationDomain, $options['honeypot_field'], $options['honeypot_message']));
 }
 /**
  * Adds a CSRF field to the form when the CSRF protection is enabled.
  *
  * @param FormBuilderInterface $builder The form builder
  * @param array                $options The options
  */
 public function buildForm(FormBuilderInterface $builder, array $options)
 {
     if (!$options['csrf_protection']) {
         return;
     }
     $builder->setAttribute('csrf_factory', $builder->getFormFactory())->addEventSubscriber(new CsrfValidationListener($options['csrf_field_name'], $options['csrf_provider'], $options['intention'], $options['csrf_message'], $this->translator, $this->translationDomain));
 }
示例#12
0
 function it_builds_form_with_proper_fields(FormBuilderInterface $builder, FormFactoryInterface $factory)
 {
     $builder->getFormFactory()->willReturn($factory);
     $builder->add('file', 'file', Argument::any())->shouldBeCalled()->willReturn($builder);
     $builder->add('code', 'text', Argument::any())->shouldBeCalled()->willReturn($builder);
     $this->buildForm($builder, []);
 }
示例#13
0
 /**
  * {@inheritdoc}
  */
 public function buildForm(FormBuilderInterface $builder, array $options)
 {
     $builder->add('presentation', 'text', array('required' => false, 'label' => 'sylius.form.variant.presentation'));
     if (!$options['master']) {
         $builder->addEventSubscriber(new BuildVariantFormListener($this->variableName, $builder->getFormFactory()));
     }
 }
示例#14
0
 /**
  * @param FormBuilderInterface $builder
  * @param array $options
  */
 public function buildForm(FormBuilderInterface $builder, array $options)
 {
     $factory = $builder->getFormFactory();
     $capituloSubscriber = new EventSuscribers\AgregarCapituloSuscriber($factory);
     $builder->addEventSubscriber($capituloSubscriber);
     $builder->add('libro', 'entity', array('class' => 'UciBaseDatosBundle:Libro', 'required' => false, 'empty_value' => 'Libro'))->add('titulo', 'textarea', array("label" => "Enunciado: ", "required" => true, "attr" => array('class' => 'form-control')))->add('numeroPagina', 'integer', array("label" => "Página Num.: ", "required" => false, 'attr' => array('min' => 0), 'precision' => 0, 'constraints' => array(new Regex(array('pattern' => '/^[0-9]\\d*$/', 'message' => 'Use solo números positivos.')))))->add('areaConocimiento', 'entity', array('class' => 'UciBaseDatosBundle:AreaConocimiento', 'required' => false, 'attr' => array('style' => 'width: 100%')))->add('trianguloTalento', 'entity', array('class' => 'UciBaseDatosBundle:TrianguloTalento', 'required' => false, 'attr' => array('style' => 'width: 100%')))->add('grupoProcesos', 'entity', array('class' => 'UciBaseDatosBundle:GrupoProcesos', 'required' => false, 'attr' => array('style' => 'width: 100%')))->add('tipoPrueba', 'entity', array('class' => 'UciBaseDatosBundle:TipoPrueba', 'expanded' => true, 'multiple' => true, 'required' => false, 'attr' => array('style' => 'width: 100%')))->add('respuesta', 'collection', array('type' => new RespuestaType($this->idTipoRespuesta, $this->esNueva), 'prototype' => true, 'allow_add' => true, 'allow_delete' => TRUE, 'by_reference' => false, 'label' => ' ', 'options' => array('label' => false)));
 }
 /**
  * buildForm 
  * Grabs organization-specific class types
  * 
  * @param FormBuilderInterface $builder 
  * @param array $options 
  * @access public
  * @return void
  */
 public function buildForm(FormBuilderInterface $builder, array $options)
 {
     $builder->add('organization', 'entity', array('class' => 'TSKUserBundle:Organization', 'attr' => array('class' => 'input-medium')));
     $factory = $builder->getFormFactory();
     $builder->addEventListener(FormEvents::PRE_BIND, function (FormEvent $event) use($factory) {
         $form = $event->getForm();
         $data = $event->getData();
         $organization = !empty($data['organization']) ? $data['organization'] : '';
         $school = !empty($data['school']) ? $data['school'] : '';
         if ($organization) {
             $form->add($factory->createNamed('school', 'entity', NULL, array('class' => 'TSKSchoolBundle:School', 'data' => $school, 'required' => true, 'attr' => array('class' => 'input-medium'), 'empty_value' => '-- Select School', 'query_builder' => function (EntityRepository $er) use($organization) {
                 return $er->createQueryBuilder('s')->innerJoin('s.contact', 'c', 'WITH', 'c.organization = :organization')->setParameter(':organization', $organization);
             })));
         }
     });
     $builder->addEventListener(FormEvents::PRE_SET_DATA, function (FormEvent $event) use($factory) {
         $form = $event->getForm();
         $data = $event->getData();
         $organization = $data->getOrganization();
         $school = $data->getSchool();
         if ($organization) {
             $form->add($factory->createNamed('school', 'entity', NULL, array('class' => 'TSK\\SchoolBundle\\Entity\\School', 'data' => $school, 'required' => true, 'empty_value' => '-- Select School', 'attr' => array('class' => 'input-medium'), 'query_builder' => function (EntityRepository $er) use($organization) {
                 return $er->createQueryBuilder('s')->innerJoin('s.contact', 'c', 'WITH', 'c.organization = :organization')->setParameter(':organization', $organization);
             })));
         }
     });
 }
示例#16
0
 function it_builds_form_with_proper_fields(FormBuilderInterface $builder, FormFactoryInterface $factory)
 {
     $builder->getFormFactory()->willReturn($factory);
     $builder->addEventSubscriber(Argument::type(AddCodeFormSubscriber::class))->shouldBeCalled()->willReturn($builder);
     $builder->add('file', 'file', Argument::any())->shouldBeCalled()->willReturn($builder);
     $this->buildForm($builder, []);
 }
示例#17
0
 public function buildForm(FormBuilderInterface $builder, array $options)
 {
     $this->factory = $builder->getFormFactory();
     $this->builder = $builder;
     $builder->add('name', 'text')->add('master', 'checkbox')->add('type', 'integer')->add('minimalFee', 'integer');
     $builder->addEventListener(FormEvents::PRE_SET_DATA, array($this, 'addFees'));
 }
 public function buildForm(FormBuilderInterface $builder, array $options)
 {
     $builder->add('type', 'choice', array('choices' => Beneficiary::getTypeChoices()))->add('first_name', 'text', array('required' => true))->add('middle_name', 'text', array('required' => false))->add('last_name', 'text', array('required' => true))->add('birth_date', 'date', array('widget' => 'single_text', 'format' => 'MM-dd-yyyy', 'attr' => array('class' => 'jq-date input-small')))->add('city', 'text', array('required' => true))->add('street', 'text', array('required' => true))->add('state', 'entity', array('class' => 'WealthbotAdminBundle:State', 'label' => 'State', 'empty_value' => 'Select a State'))->add('zip', 'text', array('required' => true))->add('relationship', 'text', array('required' => true))->add('share', 'number', array('required' => true));
     $factory = $builder->getFormFactory();
     $showSsn = $this->showSsn;
     $updateSsn = function (FormInterface $form, $ssn) use($factory) {
         $form->add($factory->createNamed('ssn_1', 'text', null, array('property_path' => false, 'attr' => array('value' => $ssn[1]), 'constraints' => array(new NotBlank(array('message' => 'Can not be blank.')), new Regex(array('pattern' => '/^\\d+$/', 'message' => 'Must be number.')), new Length(array('min' => 3, 'max' => 3, 'minMessage' => 'Must have {{ limit }} digits.', 'maxMessage' => 'Must have {{ limit }} digits.'))))))->add($factory->createNamed('ssn_2', 'text', null, array('property_path' => false, 'attr' => array('value' => $ssn[2]), 'constraints' => array(new NotBlank(array('message' => 'Can not be blank.')), new Regex(array('pattern' => '/^\\d+$/', 'message' => 'Must be number.')), new Length(array('min' => 2, 'max' => 2, 'minMessage' => 'Must have {{ limit }} digits.', 'maxMessage' => 'Must have {{ limit }} digits.'))))))->add($factory->createNamed('ssn_3', 'text', null, array('property_path' => false, 'attr' => array('value' => $ssn[3]), 'constraints' => array(new NotBlank(array('message' => 'Can not be blank.')), new Regex(array('pattern' => '/^\\d+$/', 'message' => 'Must be number.')), new Length(array('min' => 4, 'max' => 4, 'minMessage' => 'Must have {{ limit }} digits.', 'maxMessage' => 'Must have {{ limit }} digits.'))))));
     };
     $builder->addEventListener(FormEvents::PRE_BIND, function (FormEvent $event) use($updateSsn) {
         $form = $event->getForm();
         $data = $event->getData();
         if (array_key_exists('ssn_1', $data) && array_key_exists('ssn_2', $data) && array_key_exists('ssn_3', $data)) {
             $updateSsn($form, array('', $data['ssn_1'], $data['ssn_2'], $data['ssn_3']));
         }
     });
     $builder->addEventListener(FormEvents::PRE_SET_DATA, function (FormEvent $event) use($updateSsn, $showSsn) {
         $form = $event->getForm();
         $data = $event->getData();
         $ssn = array('', '', '', '');
         if (true === $showSsn) {
             if ($data !== null && preg_match('/^([0-9]{3})([0-9]{2})([0-9]{4})$/', $data->getSsn(), $matches)) {
                 $ssn = $matches;
             }
         }
         $updateSsn($form, $ssn);
     });
     $builder->addEventListener(FormEvents::BIND, array($this, 'validatePreSave'));
     if (!$this->isPreSaved) {
         $builder->addEventListener(FormEvents::BIND, array($this, 'validate'));
     }
 }
示例#19
0
 /**
  * {@inheritdoc}
  */
 public function addEntityFields(FormBuilderInterface $builder)
 {
     // user fields
     $builder->addEventSubscriber(new UserSubscriber($builder->getFormFactory(), $this->security));
     $this->setDefaultUserFields($builder);
     if ($this->securityFacade->isGranted('oro_user_role_view')) {
         $builder->add('roles', 'entity', ['property_path' => 'rolesCollection', 'label' => 'oro.user.roles.label', 'class' => 'OroUserBundle:Role', 'property' => 'label', 'query_builder' => function (EntityRepository $er) {
             return $er->createQueryBuilder('r')->where('r.role <> :anon')->setParameter('anon', User::ROLE_ANONYMOUS)->orderBy('r.label');
         }, 'multiple' => true, 'expanded' => true, 'required' => !$this->isMyProfilePage, 'read_only' => $this->isMyProfilePage, 'disabled' => $this->isMyProfilePage, 'translatable_options' => false]);
     }
     if ($this->securityFacade->isGranted('oro_user_group_view')) {
         $builder->add('groups', 'entity', ['label' => 'oro.user.groups.label', 'class' => 'OroUserBundle:Group', 'property' => 'name', 'multiple' => true, 'expanded' => true, 'required' => false, 'read_only' => $this->isMyProfilePage, 'disabled' => $this->isMyProfilePage, 'translatable_options' => false]);
     }
     if ($this->securityFacade->isGranted('oro_organization_view') && $this->securityFacade->isGranted('oro_business_unit_view')) {
         $builder->add('organizations', 'oro_organizations_select', ['required' => false, 'label' => 'oro.user.form.access_settings.label']);
     }
     $builder->add('plainPassword', 'repeated', ['label' => 'oro.user.password.label', 'type' => 'password', 'required' => true, 'first_options' => ['label' => 'oro.user.password.label'], 'second_options' => ['label' => 'oro.user.password_re.label']])->add('emails', 'collection', ['label' => 'oro.user.emails.label', 'type' => 'oro_user_email', 'allow_add' => true, 'allow_delete' => true, 'by_reference' => false, 'prototype' => true, 'prototype_name' => 'tag__name__']);
     if ($this->userConfigManager->get('oro_imap.enable_google_imap')) {
         $builder->add('imapAccountType', 'oro_imap_choice_account_type', ['label' => 'oro.user.imap_configuration.label']);
     } else {
         $builder->add('imapConfiguration', 'oro_imap_configuration', ['label' => 'oro.user.imap_configuration.label']);
     }
     $builder->add('change_password', ChangePasswordType::NAME)->add('avatar', 'oro_image', ['label' => 'oro.user.avatar.label', 'required' => false]);
     $this->addInviteUserField($builder);
 }
 /**
  * {@inheritdoc}
  */
 public function buildForm(FormBuilderInterface $builder, array $options)
 {
     $builder->add('mrn', 'text', array('label' => 'accard.patient.form.mrn', 'required' => false))->add('firstName', 'text', array('label' => 'accard.patient.form.first_name', 'required' => true))->add('lastName', 'text', array('label' => 'accard.patient.form.last_name', 'required' => true))->add('dateOfBirth', 'birthday', array('label' => 'accard.patient.form.date_of_birth', 'required' => true))->add('dateOfDeath', 'date', array('label' => 'accard.patient.form.date_of_death', 'required' => false))->add('gender', 'choice', array('label' => 'accard.patient.form.gender', 'required' => true, 'placeholder' => 'accard.patient.action.choose_gender', 'choices' => $this->prepareChoices(Patient::getAvailableGenders(), 'gender')))->add('race', 'choice', array('label' => 'accard.patient.form.race', 'required' => true, 'placeholder' => 'accard.patient.action.choose_race', 'choices' => $this->prepareChoices(Patient::getAvailableRaces(), 'race')))->add('fields', 'collection', array('required' => false, 'type' => 'accard_patient_field_value', 'allow_add' => true, 'allow_delete' => true, 'by_reference' => false))->addEventSubscriber(new DefaultPatientFieldListener($builder->getFormFactory(), $this->patientBuilder));
     if ($options['use_phases']) {
         $builder->add('phases', 'collection', array('required' => false, 'type' => 'accard_patient_phase_instance', 'allow_add' => true, 'allow_delete' => true, 'by_reference' => false, 'options' => array('use_target' => false)));
     }
 }
 function it_builds_a_form(FormBuilderInterface $builder, FormFactoryInterface $factory)
 {
     $builder->getFormFactory()->willReturn($factory);
     $builder->add('type', 'sylius_promotion_action_choice', Argument::type('array'))->shouldBeCalled()->willReturn($builder);
     $builder->addEventSubscriber(Argument::type(BuildPromotionActionFormSubscriber::class))->shouldBeCalled()->willReturn($builder);
     $this->buildForm($builder, ['configuration_type' => 'configuration_form_type']);
 }
 /**
  * {@inheritdoc}
  */
 public function buildForm(FormBuilderInterface $builder, array $options)
 {
     $builder->add('definition', 'hidden', array('required' => false));
     $factory = $builder->getFormFactory();
     $that = $this;
     $builder->addEventListener(FormEvents::PRE_SET_DATA, function (FormEvent $event) use($that, $factory) {
         $form = $event->getForm();
         /** @var AbstractQueryDesigner $data */
         $data = $event->getData();
         if ($data) {
             $entity = $data->getEntity();
         } else {
             $entity = null;
         }
         $that->addFields($form, $factory, $entity);
     });
     $builder->addEventListener(FormEvents::PRE_SUBMIT, function (FormEvent $event) use($that, $factory) {
         $form = $event->getForm();
         /** @var AbstractQueryDesigner $data */
         $data = $event->getData();
         if ($data) {
             $entity = $data['entity'];
         } else {
             $entity = null;
         }
         $that->addFields($form, $factory, $entity);
     });
 }
 /**
  * Adds a CSRF field to the form when the CSRF protection is enabled.
  *
  * @param FormBuilderInterface $builder The form builder
  * @param array                $options The options
  */
 public function buildForm(FormBuilderInterface $builder, array $options)
 {
     if (!$options['csrf_protection']) {
         return;
     }
     $builder->setAttribute('csrf_factory', $builder->getFormFactory())->addEventSubscriber(new CsrfValidationListener($options['csrf_field_name'], $options['csrf_provider'], $options['intention'] ?: ($builder->getName() ?: get_class($builder->getType()->getInnerType()))));
 }
示例#24
0
 public function buildForm(FormBuilderInterface $builder, array $options)
 {
     $builder->add('calle', 'text');
     $builder->add('numero', 'text');
     $builder->add('piso');
     $builder->add('depto');
     $builder->add('lat');
     $builder->add('lon');
     $builder->add('zip', 'text', array('required' => true));
     $builder->add('tipo', 'entity', array('class' => 'BackendCustomerAdminBundle:TipoDireccion', 'property' => 'name', 'multiple' => false));
     $builder->add('isDefault', 'checkbox', array('value' => 1, 'label' => "Direccion por defecto", 'required' => false));
     $zonaSubscriber = new ZonaSubscriber($builder->getFormFactory());
     $builder->addEventSubscriber($zonaSubscriber);
     $barrioSubscriber = new BarrioSubscriber($builder->getFormFactory());
     $builder->addEventSubscriber($barrioSubscriber);
 }
 public function buildForm(FormBuilderInterface $builder, array $options)
 {
     $adm = new AccountDocusignManager($this->em, 'Wealthbot\\ClientBundle\\Entity\\ClientAccountDocusign');
     if ($this->account->hasGroup(AccountGroup::GROUP_DEPOSIT_MONEY) || true === $this->hasFunding || $adm->hasElectronicallySignError($this->account)) {
         $subscriber = new TransferFundingFormEventSubscriber($builder->getFormFactory(), $this->em, $this->account);
         $builder->add('funding', new TransferFundingFormType($this->em, $this->account, $subscriber, $this->isPreSaved), array('label' => null));
     }
 }
 public function buildForm(FormBuilderInterface $builder, array $options)
 {
     $builder->add('is_firm_not_appear', 'checkbox', array('mapped' => false, 'required' => false))->add('transfer_custodian_id', 'hidden', array('property_path' => false));
     $this->factory = $builder->getFormFactory();
     $builder->addEventListener(FormEvents::PRE_SET_DATA, array($this, 'onPreSetData'));
     $builder->addEventListener(FormEvents::PRE_BIND, array($this, 'onPreBind'));
     $builder->addEventListener(FormEvents::BIND, array($this, 'onBind'));
 }
示例#27
0
 public function buildForm(FormBuilderInterface $builder, array $options)
 {
     $this->config = $this->configProvider->getConfigById($options['config_id']);
     $this->formFactory = $builder->getFormFactory();
     $builder->add('target_entity', new TargetType($this->configProvider, $options['config_id']), ['constraints' => [new Assert\NotBlank()]]);
     $builder->addEventListener(FormEvents::PRE_SET_DATA, array($this, 'preSubmitData'));
     $builder->addEventListener(FormEvents::PRE_SUBMIT, array($this, 'preSubmitData'));
 }
 /**
  * @param FormBuilderInterface $builder
  * @param array $options
  */
 public function buildForm(FormBuilderInterface $builder, array $options)
 {
     $factory = $builder->getFormFactory();
     $builder->addEventSubscriber(new AddPaisFieldSubscriber($factory));
     $builder->addEventSubscriber(new AddProvinciaFieldSubscriber($factory));
     $builder->addEventSubscriber(new AddDepartamentoFieldSubscriber($factory));
     $builder->addEventSubscriber(new AddLocalidadFieldSubscriber($factory));
 }
 function it_builds_form_with_proper_fields(FormBuilderInterface $builder, FormFactoryInterface $factory)
 {
     $builder->getFormFactory()->willReturn($factory);
     $builder->add('name', 'text', Argument::any())->shouldBeCalled()->willReturn($builder);
     $builder->add('permalink', 'text', Argument::any())->shouldBeCalled()->willReturn($builder);
     $builder->add('description', 'textarea', Argument::any())->shouldBeCalled()->willReturn($builder);
     $this->buildForm($builder, []);
 }
示例#30
-1
 public function buildForm(FormBuilderInterface $builder, array $options)
 {
     // You could tag the permission managers and then get them
     // here instead of hard coding ...
     $builder->add('permissionType', 'choice', array('choices' => array('admin' => 'sonata admins', 'object' => 'objects', 'route' => 'routes'), 'label' => 'Permission Type'));
     $builder->add('identity', 'tsk_identity_dropdown');
     $builder->add('identityType', 'hidden');
     $factory = $builder->getFormFactory();
     // We use a closure to populate permissions and masks for user
     $refreshPerms = function ($form, $perms) use($factory) {
         $form->add($factory->createNamed('permissions', 'collection', $perms, array('type' => 'tsk_permission_type', 'options' => array('label_attr' => array('class' => 'perm-collection')))));
     };
     //
     // Use FormEvents to add the permissions array dynamically
     //
     $builder->addEventListener(FormEvents::PRE_BIND, function (FormEvent $event) use($factory, $refreshPerms) {
         $form = $event->getForm();
         $data = $event->getData();
         if (!empty($data['identity'])) {
             $perms = $this->permissionsManager->getPermissionsForIdentity($data['identity'], $data['identityType']);
             $refreshPerms($form, $perms);
         }
     });
     $builder->addEventListener(FormEvents::PRE_SET_DATA, function (FormEvent $event) use($factory, $refreshPerms) {
         $form = $event->getForm();
         $data = $event->getData();
         if ($data->getIdentity()) {
             $perms = $this->permissionsManager->getPermissionsForIdentity($data->getIdentity(), $data->getIdentityType());
             $refreshPerms($form, $perms);
         }
     });
 }