Ejemplo n.º 1
0
 /**
  * Add the types related to the LinkType value.
  *
  * @param                                    $linkType
  * @param                                    $locale
  * @param FormBuilderInterface|FormInterface $form
  * @param FormBuilderInterface               $builder
  */
 protected function manageLinkTypeRelatedFields($linkType, $locale, $form, FormBuilderInterface $builder)
 {
     $form->remove('route');
     $form->remove('url');
     $form->remove('attachedWidget');
     $form->remove('viewReference');
     $form->remove('locale');
     switch ($linkType) {
         case Link::TYPE_VIEW_REFERENCE:
             $locale = $locale ?: $this->requestStack->getCurrentRequest()->getLocale();
             $form->add('viewReference', ChoiceType::class, ['label' => 'form.link_type.view_reference.label', 'required' => true, 'attr' => ['novalidate' => 'novalidate'], 'placeholder' => 'form.link_type.view_reference.blank', 'choices' => $this->viewReferenceRepository->getChoices($locale), 'choices_as_values' => true, 'vic_vic_widget_form_group_attr' => ['class' => 'vic-form-group']])->add('locale', ChoiceType::class, ['label' => 'form.link_type.locale.label', 'choices' => array_combine($this->availableLocales, $this->availableLocales), 'attr' => ['data-refreshOnChange' => 'true']]);
             break;
         case Link::TYPE_ROUTE:
             $form->add('route', null, ['label' => 'form.link_type.route.label', 'vic_vic_widget_form_group_attr' => ['class' => 'vic-form-group'], 'required' => true, 'attr' => ['novalidate' => 'novalidate', 'placeholder' => 'form.link_type.route.placeholder']])->add('route_parameters', JsonType::class, ['label' => 'form.link_type.route_parameters.label', 'vic_vic_widget_form_group_attr' => ['class' => 'vic-form-group'], 'required' => true, 'attr' => ['novalidate' => 'novalidate', 'placeholder' => 'form.link_type.route_parameters.placeholder']]);
             break;
         case Link::TYPE_URL:
             $form->add('url', null, ['label' => 'form.link_type.url.label', 'vic_vic_widget_form_group_attr' => ['class' => 'vic-form-group'], 'required' => true, 'attr' => ['novalidate' => 'novalidate', 'placeholder' => 'form.link_type.url.placeholder']]);
             break;
         case Link::TYPE_WIDGET:
             $form->add('attachedWidget', EntityType::class, ['label' => 'form.link_type.attachedWidget.label', 'placeholder' => 'form.link_type.attachedWidget.blank', 'class' => 'VictoireWidgetBundle:Widget', 'vic_vic_widget_form_group_attr' => ['class' => 'vic-form-group'], 'required' => true, 'attr' => ['novalidate' => 'novalidate']]);
             break;
         case Link::TYPE_NONE:
         case null:
             $form->remove('target');
             break;
     }
 }
Ejemplo n.º 2
0
 public function buildForm(FormBuilderInterface $builder, array $options)
 {
     $builder->remove('plainPassword');
     $builder->remove('username');
     $builder->remove('email');
     $builder->add('firstName', null, ['label' => 'Voornaam']);
     $builder->add('lastName', null, ['label' => 'Achternaam']);
     $builder->add('email', EmailType::class, ['label' => 'Email']);
     $builder->add('phone', null, ['label' => 'Telefoon']);
 }
Ejemplo n.º 3
0
 /**
  * {@inheritdoc}
  */
 public function buildForm(FormBuilderInterface $builder, array $options)
 {
     $dateOptions = $builder->get('date')->getOptions();
     $timeOptions = $builder->get('time')->getOptions();
     $builder->remove('date')->add('date', 'datepicker', $dateOptions);
     if (isset($options['preferred_choices'])) {
         $timeOptions = array_merge($timeOptions, array('hours' => $options['preferred_choices']['hours'], 'minutes' => $options['preferred_choices']['minutes']));
         $builder->remove('time')->add('time', 'time', $timeOptions);
     }
 }
 public function buildForm(FormBuilderInterface $builder, array $options)
 {
     // add your custom field
     $builder->remove('username');
     $builder->remove('email');
     $builder->remove('plainPassword');
     $builder->add('firstName', null, ['label' => 'Voornaam', 'constraints' => [new NotBlank()]]);
     $builder->add('lastName', null, ['label' => 'Achternaam', 'constraints' => [new NotBlank()]]);
     $builder->add('phone', null, ['label' => 'Telefoon', 'constraints' => [new NotBlank(), new Length(["min" => 10, "max" => 10])]]);
     $builder->add('email', LegacyFormHelper::getType('Symfony\\Component\\Form\\Extension\\Core\\Type\\EmailType'), array('label' => 'form.email', 'translation_domain' => 'FOSUserBundle'));
     $builder->add('plainPassword', LegacyFormHelper::getType('Symfony\\Component\\Form\\Extension\\Core\\Type\\RepeatedType'), array('type' => LegacyFormHelper::getType('Symfony\\Component\\Form\\Extension\\Core\\Type\\PasswordType'), 'options' => array('translation_domain' => 'FOSUserBundle'), 'first_options' => array('label' => 'form.password'), 'second_options' => array('label' => 'form.password_confirmation'), 'invalid_message' => 'fos_user.password.mismatch'));
 }
Ejemplo n.º 5
0
 public function buildForm(FormBuilderInterface $builder, array $options)
 {
     // add your custom field
     $builder->add('city', null, array('label' => 'Miestas'));
     $builder->add('address', null, array('label' => 'Adresas'));
     $builder->add('phoneNumber', null, array('label' => 'Tel. nr'));
     $builder->add('profilePictureFile', null, array('label' => 'Nuotrauka'));
     $builder->add('description', TextareaType::class, array('label' => 'Aprašymas', 'attr' => array('cols' => '20', 'rows' => '5')));
     $builder->add('startTime', TimeType::class, array('label' => 'Darbo laiko pradžia', 'placeholder' => array('hour' => 'Valanda'), 'data' => new \DateTime('2015-09-09 08:00:00')));
     $builder->add('endTime', TimeType::class, array('label' => 'Darbo laiko pabaiga', 'placeholder' => array('hour' => 'Valanda'), 'data' => new \DateTime('2015-09-09 18:00:00')));
     $builder->remove('current_password');
     $builder->remove('username');
     //...............
     //Add all your properties here with $builder->add('property name')
 }
Ejemplo n.º 6
0
 /**
  * {@inheritdoc}
  */
 public function buildForm(FormBuilderInterface $builder, array $options)
 {
     $builder->add('enabled', BooleanType::class)->add('confirmed', BooleanType::class);
     if ($this->isOtherUser($builder->getData())) {
         $builder->remove('password');
     }
 }
Ejemplo n.º 7
0
 public function buildForm(FormBuilderInterface $builder, array $options)
 {
     $id = $builder->getData()->getId();
     $builder->remove('metaId')->add('defaultBranch', 'entity', array('class' => 'HLPNebulaBundle:Branch', 'expanded' => false, 'multiple' => false, 'mapped' => false, 'query_builder' => function (\HLP\NebulaBundle\Entity\BranchRepository $repo) use($id) {
         return $repo->getBranchQueryBuilder($id);
     }));
 }
Ejemplo n.º 8
0
 /**
  * {@inheritdoc}
  */
 public function remove($key)
 {
     $this->admin->removeFormFieldDescription($key);
     $this->admin->removeFieldFromFormGroup($key);
     $this->formBuilder->remove($key);
     return $this;
 }
Ejemplo n.º 9
0
 public function buildForm(FormBuilderInterface $builder, array $options)
 {
     $builder->add('type', 'choice', array('label' => 'I am a', 'choices' => array(User::ROLE_STUDENT => 'Student', User::ROLE_GS1_MEMBER => 'Member'), 'data' => 'student', 'attr' => array('class' => 'account_type')))->add('firstName', null, array('attr' => array('maxlength' => false), 'render_required_asterisk' => true))->add('lastName', null, array('attr' => array('maxlength' => false), 'render_required_asterisk' => true))->add('email', 'email', array('label' => 'form.email', 'translation_domain' => 'FOSUserBundle', 'render_required_asterisk' => true))->add('plainPassword', 'repeated', array('type' => 'password', 'options' => array('translation_domain' => 'FOSUserBundle'), 'first_options' => array('label' => 'form.password', 'render_required_asterisk' => true), 'second_options' => array('label' => 'form.password_confirmation', 'render_required_asterisk' => true), 'invalid_message' => 'fos_user.password.mismatch'))->add('toc', 'checkbox', array('mapped' => false, 'label' => 'I agree to <a id="toc" href="#">terms & conditions</a>', 'constraints' => array(new IsTrue(array('message' => 'You must agree to terms & conditions')))))->add('studentProfile', new StudentRegistrationType($this->entityManager), array('label' => false, 'widget_form_group' => false, 'widget_type' => 'inline'));
     $builder->get('email')->setAttribute('render_required_asterisk', true);
     $builder->get('plainPassword')->setAttribute('render_required_asterisk', true);
     $builder->remove('username');
     $formModifier = function (FormInterface $form, $type = null) {
         if ($type === User::ROLE_GS1_MEMBER) {
             $form->add('memberProfile', new MemberProfileType(), array('label' => false, 'widget_form_group' => false, 'widget_type' => 'inline', 'constraints' => array(new Valid())))->remove("studentProfile");
         }
     };
     $builder->addEventListener(FormEvents::PRE_SET_DATA, function (FormEvent $event) use($formModifier) {
         $data = $event->getData();
         $formModifier($event->getForm(), $data !== null ? $data->getType() : null);
     });
     $builder->get('type')->addEventListener(FormEvents::POST_SUBMIT, function (FormEvent $event) use($formModifier) {
         $type = $event->getForm()->getData();
         $formModifier($event->getForm()->getParent(), $type);
     });
     $builder->addEventListener(FormEvents::POST_SUBMIT, function (FormEvent $event) {
         $form = $event->getForm();
         if ($form->getErrors(true)->count() > 0) {
             $form->get('plainPassword')->get('first')->addError(new FormError('The form is invalid, you must re-enter your password'));
         }
     });
     //        $builder->get('activatedAccessCode')
     //            ->addModelTransformer(new StudentAccessCodeTransformer($this->entityManager));
 }
 /**
  * @param FormBuilderInterface $builder
  * @param array $options
  */
 public function buildForm(FormBuilderInterface $builder, array $options)
 {
     $builder->remove('username');
     $builder->add('firstname', 'text', array('label' => 'register.form.firstname.label'))->add('lastname', 'text', array('label' => 'register.form.lastname.label'))->add('email', 'text', array('label' => 'register.form.email.label'))->add('plainPassword', 'repeated', array('type' => 'password', 'first_options' => array('label' => 'register.form.password.label'), 'second_options' => array('label' => 'register.form.password-confirm.label'), 'invalid_message' => 'fos_user.password.mismatch'));
     $builder->add('registered_disability_group', 'fieldset', ['label' => false, 'legend' => 'register.form.registered-disability-group.legend', 'fields' => [['name' => 'phoneNumber', 'type' => new PhoneNumberEntityFormType(), 'attr' => []], ['name' => 'registration', 'type' => new RegistrationEntityFormType(), 'attr' => []]]]);
     $builder->add('registerButton', 'submit', array('label' => 'register.form.register-button.label'));
 }
 public function buildForm(FormBuilderInterface $builder, array $options)
 {
     $dateOptions = $builder->get('date')->getOptions();
     $options = array('html5' => false, 'format' => 'dd/MM/yyyy', 'attr' => array('class' => 'datepicker'));
     $dateOptions = array_merge($dateOptions, $options);
     $builder->remove('date')->add('date', 'dspsofts_date_picker', $dateOptions);
 }
Ejemplo n.º 12
0
 public function buildForm(FormBuilderInterface $builder, array $options)
 {
     $builder->add('language', ChoiceType::class, array('label' => 'Language', 'choices' => ['es' => 'Español', 'en' => 'English']));
     $builder->add('bio', TextareaType::class, array('label' => 'Biography', 'required' => false));
     $builder->add('country', CountryType::class, array('label' => 'Country', 'translation_domain' => 'messages'));
     $builder->add('birthday', BirthdayType::class, array('label' => 'Birthday', 'years' => range(date('Y'), 1900)));
     $builder->remove('current_password');
 }
Ejemplo n.º 13
0
 /**
  * @param FormBuilderInterface $builder
  * @param array $options
  */
 public function buildForm(FormBuilderInterface $builder, array $options)
 {
     $id = $builder->getData()->getBranch()->getMeta()->getId();
     $exclude = $builder->getData()->getBranch()->getId();
     $builder->remove('folder')->remove('packages')->remove('actions')->add('branch', 'entity', array('class' => 'HLPNebulaBundle:Branch', 'expanded' => false, 'multiple' => false, 'query_builder' => function (\HLP\NebulaBundle\Entity\BranchRepository $repo) use($id, $exclude) {
         return $repo->getBranchQueryBuilder($id, $exclude);
     }));
 }
Ejemplo n.º 14
0
 public function buildForm(FormBuilderInterface $builder, array $options)
 {
     $builder->remove('username');
     $builder->add('first_name', 'text', ['label' => 'user.name']);
     $builder->add('last_name', 'text', ['label' => 'user.surname']);
     $builder->add('phone', 'text', ['label' => 'user.phone']);
     $builder->add('birthday', 'birthday', ['label' => 'user.birth_year']);
     $builder->add('description', 'textarea', ['label' => "user.about_me", 'required' => true, 'attr' => ['data-help' => 'user.short_about_me_desc']]);
 }
Ejemplo n.º 15
0
 static function baseBuildForm(FormBuilderInterface $builder)
 {
     $builder->remove('username')->add('firstName', 'text', ['attr' => ['placeholder' => 'form.profile.firstName'], 'label' => 'form.profile.firstName', 'translation_domain' => 'FOSUserBundle'])->add('lastName', 'text', ['attr' => ['placeholder' => 'form.profile.lastName'], 'label' => 'form.profile.lastName', 'translation_domain' => 'FOSUserBundle']);
     $genderArr = [];
     $arr = Type::getType('genderEnumType')->getChoices();
     foreach ($arr as $key => $value) {
         $genderArr[$key] = 'form.gender.' . $key;
     }
     $builder->add('gender', 'choice', ['label' => 'form.profile.gender', 'choices' => $genderArr, 'translation_domain' => 'FOSUserBundle']);
 }
Ejemplo n.º 16
0
 public function buildForm(FormBuilderInterface $builder, array $options)
 {
     $builder->remove('username');
     $builder->add('first_name', 'text', array("label" => "user.label_name", "required" => true));
     $builder->add('last_name', 'text', array("label" => "user.label_surname", "required" => true));
     $builder->add('phone', 'text', array("label" => "user.label.phone", "required" => true));
     $builder->add('birthday', 'birthday', array("label" => "user.birth_year", "required" => true, 'years' => range(date('Y') - 18, date('Y') - 100)));
     $builder->add('description', 'textarea', array('label' => "user.about_me", 'required' => true, 'attr' => ['data-help' => 'user.short_about_me_desc']));
     /*$builder->add('field', 'text', ['label' => 'user.short_about_me_desc']);*/
 }
Ejemplo n.º 17
0
 /**
  * @param FormBuilderInterface $builder
  * @param array $options
  */
 public function buildForm(FormBuilderInterface $builder, array $options)
 {
     $transformer = new NameToIdTransformer($this->entityManager);
     $builder->add('title', 'text', array('attr' => array('class' => 'form-control', 'placeholder' => 'Smartphone derniere génération bonne qualité..')))->add('price', 'text', array('required' => false, 'attr' => array('class' => 'form-control', 'placeholder' => '0,00€')))->add('description', 'textarea', array('attr' => array('class' => 'form-control', 'placeholder' => 'Décrivez votre annonce')))->add('delivery', 'checkbox', array('required' => false))->add('negotiable', 'checkbox', array('required' => false))->add('exchange', 'checkbox', array('required' => false))->add('private', 'checkbox', array('required' => false))->add('commentable', 'checkbox', array('required' => false))->add('showphone', 'checkbox', array('required' => false))->add('cheque', 'checkbox', array('required' => false))->add('espece', 'checkbox', array('required' => false))->add('cb', 'checkbox', array('required' => false))->add('paypal', 'checkbox', array('required' => false))->add('urgent', 'checkbox', array('required' => false))->add('category', 'entity', array('attr' => array('class' => 'form-control categoryclass'), 'required' => true, 'class' => 'SnoozitPlatformBundle:Categories\\Category', 'choice_label' => 'category', 'group_by' => 'parentcategory.parent', 'empty_value' => 'La rubrique'))->add('pictureOne', new AdvertPictureType(), array('label' => false, 'required' => false, 'attr' => array('rel' => 1)))->add('pictureTwo', new AdvertPictureType(), array('label' => false, 'required' => false, 'attr' => array('rel' => 2)))->add('pictureThree', new AdvertPictureType(), array('label' => false, 'required' => false, 'attr' => array('rel' => 3)))->add('pictureFour', new AdvertPictureType(), array('label' => false, 'required' => false, 'attr' => array('rel' => 4)));
     $builder->remove('slug')->remove('hash')->remove('success')->remove('created')->remove('user')->remove('updated')->remove('combinaisonRequest')->remove('contentChanged');
     if (!is_object($this->user) || !$this->user instanceof UserInterface) {
         $builder->add($builder->create('city', 'text', array('label' => 'Ville sélectionnée', 'attr' => array('data-id' => 'city', 'class' => 'form-control input-sm', 'readonly' => true, 'placeholder' => 'Ville choisie')))->addModelTransformer($transformer))->add('codePostal', 'text', array('mapped' => false, 'label' => 'Code postal', 'attr' => array('data-id' => 'codePostal', 'class' => 'form-control input-sm', 'max-lenght' => 5, 'placeholder' => '13100')));
     }
     $builder->addEventListener(FormEvents::PRE_SET_DATA, array($this, 'onPreSetData'));
 }
Ejemplo n.º 18
0
 /**
  * Buildform function
  *
  * @param FormBuilderInterface $builder the formBuilder
  * @param array                $options the options for this form
  */
 public function buildForm(FormBuilderInterface $builder, array $options)
 {
     /**
      * @var Plugin $plugin
      */
     $plugin = $options['plugin'];
     foreach ($plugin->getFields() as $fieldName => $field) {
         $builder->remove($fieldName)->add($fieldName, $field['type'], array_merge(['label' => $field['label'], 'data' => $field['data'], 'required' => $field['required'], 'attr' => $field['attr']], $field['options']), $field);
     }
     $builder->add('save', 'submit');
 }
Ejemplo n.º 19
0
 public function buildForm(FormBuilderInterface $builder, array $options)
 {
     $builder->remove('roles')->remove('plainPassword');
     if ($this->authorizationChecker->isGranted('ROLE_ADMIN')) {
         $builder->addEventListener(FormEvents::PRE_SET_DATA, function (FormEvent $event) {
             //add roles fields if ADMIN
             $form = $event->getForm();
             $form->add('roles', 'choice', array('label' => false, 'choices' => array('ROLE_USER' => 'Utilisateur', 'ROLE_ADMIN' => 'Administrateur', 'ROLE_AUTEUR' => 'Auteur'), 'multiple' => true, 'attr' => array('class' => 'form-control')));
         });
     }
 }
Ejemplo n.º 20
0
 public function buildForm(FormBuilderInterface $builder, array $options)
 {
     $builder->add('plainPassword', 'repeated', array('type' => 'password', 'options' => array('translation_domain' => 'FOSUserBundle'), 'first_options' => array('label' => 'form.new_password'), 'second_options' => array('label' => 'form.new_password_confirmation'), 'invalid_message' => 'fos_user.password.mismatch'));
     $builder->remove('current_password');
     if ($this->auth->isGranted('ROLE_ADMIN')) {
         $builder->add('publisher', 'entity', array('class' => 'KingdomHall\\DataBundle\\Entity\\Publisher', 'label' => 'jwkh.entity.publisher.entity', 'expanded' => false, 'multiple' => false, 'property' => 'fullName', 'query_builder' => function (EntityRepository $er) {
             return $er->createQueryBuilder('p')->where('p.deleted = false');
         }));
         $builder->add('roles', 'collection', array('label' => 'Role', 'type' => 'choice', 'options' => array('choices' => User::$ROLES)));
     }
 }
 public function buildForm(FormBuilderInterface $builder, array $options)
 {
     $builder->add('lastName');
     $builder->add('firstName');
     $builder->remove('username');
     $builder->add('gender', 'choice', array('choices' => array('M' => 'Homme', 'F' => 'Femme'), 'required' => true, 'placeholder' => 'Sexe'));
     $builder->add('birthday', DateType::class, array('widget' => 'single_text', 'format' => 'dd/MM/yyyy', 'html5' => false, 'placeholder' => 'Date de naissance'));
     $builder->add('phoneNumber', 'text', array('required' => true));
     $builder->add('address', 'text');
     $builder->add('zipCode', 'text');
     $builder->add('city', 'text');
 }
Ejemplo n.º 22
0
 /**
  * @param FormBuilderInterface $builder
  * @param array $options
  */
 public function buildForm(FormBuilderInterface $builder, array $options)
 {
     if ($options['widget'] == 'text') {
         $group = '_' . md5(microtime() . rand(500, 500000));
         $hourOptions = $builder->get('hour')->getOptions();
         $minOptions = $builder->get('minute')->getOptions();
         $hourOptions['attr'] = array_merge($minOptions['attr'], array('size' => 1, 'maxlength' => 2, 'class' => 'gsClockPicker', 'data-clockField' => 'clockHours', 'data-clockGroup' => $group, 'data-increment' => 1));
         $minOptions['attr'] = array_merge($minOptions['attr'], array('size' => 1, 'maxlength' => 2, 'class' => 'gsClockPicker', 'data-clockField' => 'clockMinutes', 'data-clockGroup' => $group, 'data-increment' => 5));
         $builder->remove('hour')->add('hour', null, $hourOptions)->remove('minute')->add('minute', null, $minOptions);
     }
     $attr = array('class' => 'gsClockPicker', 'data-clockGroup' => $group, 'data-clockField' => 'clockMeridian');
     $builder->add('meridian', 'checkbox', array('label' => 'AM', 'attr' => $attr, 'required' => false, 'label_attr' => array('class' => 'meridian', 'required' => false)));
 }
Ejemplo n.º 23
0
 /**
  * @param FormBuilderInterface $builder
  * @param array $options
  */
 public function buildForm(FormBuilderInterface $builder, array $options)
 {
     $builder->remove('Ajouter')->add('Enregistrer', 'submit');
     // $factory = $builder->getFormFactory();
     // $builder->addEventListener(FormEvents::PRE_SET_DATA,function(FormEvent $event){
     // $evenement = $event->getData();
     // $form = $event->getForm();
     // if( $evenement->getAffiche() != null){
     // $form->remove('affiche');
     // $form->add('affiche', 'button', array('label' => 'Supprimer l\'affiche'));
     // }
     // }
     // );
 }
Ejemplo n.º 24
0
 /**
  * Supprime de la liste les rôles que n'a pas l'utilisateur
  * Et filtre la liste des rôles par ceux spécifiés
  *
  * @param FormBuilderInterface $builder
  * @param array $options
  */
 public function buildForm(FormBuilderInterface $builder, array $options)
 {
     $builder->addEventSubscriber($this->subscriber);
     $filteredChoices = array_keys($options['choices']);
     if (!empty($options['roles'])) {
         $filteredChoices = array_intersect($filteredChoices, $options['roles']);
     }
     foreach ($builder as $key => $value) {
         $role = $builder->get($key)->getOption('value');
         if (!in_array($role, $filteredChoices) || !$this->context->isGranted($role)) {
             $builder->remove($key);
         }
     }
 }
Ejemplo n.º 25
0
 /**
  * addHiddenValues
  * @param FormBuilderInterface $builder
  * @return FormBuilderInterface
  */
 public function addHiddenValues(FormBuilderInterface $builder)
 {
     $data = array();
     $nom = 'hiddenData';
     foreach ($this->parametres as $key => $value) {
         if (is_string($value) || is_array($value) || is_bool($value)) {
             $data[$key] = $value;
         }
     }
     if ($builder->has($nom)) {
         $builder->remove($nom);
     }
     $builder->add($nom, 'hidden', array('data' => urlencode(json_encode($data, true)), 'mapped' => false));
     return $builder;
 }
Ejemplo n.º 26
0
 public function buildForm(FormBuilderInterface $builder, array $options)
 {
     /** @var TaxonModel $taxon */
     $taxon = $options['data'];
     $builder->add('is_enabled', null, ['required' => false])->add('title', null, ['attr' => ['autofocus' => 'autofocus']])->add('slug')->add('is_inheritance', null, ['required' => false])->add('position')->add('parent', TaxonTreeType::class, ['unicat_structure' => $taxon->getStructure()])->add('meta', MetaFormType::class, ['label' => 'Meta tags']);
     if (!$taxon->getStructure()->isTree()) {
         $builder->remove('parent');
     }
     $structure = null;
     if (is_object($taxon) and $taxon->getStructure() instanceof UnicatStructure) {
         $structure = $taxon->getStructure();
     }
     if ($structure) {
         $properties = Yaml::parse($structure->getProperties());
         if (is_array($properties)) {
             $builder->add($builder->create('properties', TaxonPropertiesFormType::class, ['required' => false, 'properties' => $properties]));
         }
     }
 }
 /**
  * @param FormBuilderInterface $builder
  * @param array $options
  */
 public function buildForm(FormBuilderInterface $builder, array $options)
 {
     $builder->remove('category');
     // On ajoute une fonction qui va écouter un évènement
     $builder->addEventListener(FormEvents::PRE_SET_DATA, function (FormEvent $event) {
         // 2e argument : La fonction à exécuter lorsque l'évènement est déclenché
         // On récupère notre objet Materiel sous-jacent
         $materiel = $event->getData();
         $form = $event->getForm();
         if ($materiel->getCategory()->getName() === "Alimentation") {
             $form->add('tension', 'text', array('required' => false))->add('systemerefroidissement', 'text', array('required' => false))->add('capacite', 'text', array('required' => false));
         } else {
             if ($materiel->getCategory()->getName() === "Carte mère") {
                 $form->add('cpu', 'text', array('required' => false))->add('chipset', 'text', array('required' => false))->add('memoire', 'text', array('required' => false))->add('slotsextension', 'text', array('required' => false))->add('lan', 'text', array('required' => false))->add('audio', 'text', array('required' => false))->add('usb', 'text', array('required' => false));
             } else {
                 if ($materiel->getCategory()->getName() === "Carte graphique") {
                     $form->add('processeurgraphique', 'text', array('required' => false))->add('bus', 'text', array('required' => false))->add('sortiedvi', 'text', array('required' => false))->add('autresorties', 'text', array('required' => false))->add('memoire', 'text', array('required' => false));
                 } else {
                     if ($materiel->getCategory()->getName() === "Processeur") {
                         $form->add('famille', 'text', array('required' => false))->add('frequence', 'text', array('required' => false))->add('frequencemodeturbo', 'text', array('required' => false))->add('nombrecoeurs', 'integer', array('required' => false))->add('finesse', 'text', array('required' => false))->add('bits', 'text', array('required' => false))->add('taillecache', 'text', array('required' => false));
                     } else {
                         if ($materiel->getCategory()->getName() === "Carte son") {
                             $form->add('typeinterface', 'text', array('required' => false))->add('modesortie', 'text', array('required' => false))->add('audio', 'text', array('required' => false))->add('portses', 'text', array('required' => false));
                         } else {
                             if ($materiel->getCategory()->getName() === "Barrette Mémoire") {
                                 $form->add('type', 'text', array('required' => false))->add('frequence', 'text', array('required' => false))->add('capacite', 'text', array('required' => false));
                             } else {
                                 if ($materiel->getCategory()->getName() === "disque dur") {
                                     $form->add('capacite', 'text', array('required' => false))->add('typeinterface', 'text', array('required' => false))->add('memoire', 'text', array('required' => false))->add('debit', 'text', array('required' => false))->add('typechassis', 'text', array('required' => false))->add('vitesserotation', 'text', array('required' => false));
                                 }
                             }
                         }
                     }
                 }
             }
         }
         // Cette condition est importante, on en reparle plus loin
         if (null === $materiel) {
             return;
             // On sort de la fonction sans rien faire lorsque $materiel vaut null
         }
     });
 }
Ejemplo n.º 28
0
 /**
  * {@inheritdoc}
  */
 public function buildForm(FormBuilderInterface $builder, array $options)
 {
     if (is_array($options['format_field'])) {
         list($formatField, $formatPropertyPath) = $options['format_field'];
         $options['format_field_options']['property_path'] = $formatPropertyPath;
     } else {
         $formatField = $options['format_field'];
         $options['format_field_options']['property_path'] = $formatField;
     }
     if (is_array($options['source_field'])) {
         list($sourceField, $sourcePropertyPath) = $options['source_field'];
         $options['source_field_options']['property_path'] = $sourcePropertyPath;
     } else {
         $sourceField = $options['source_field'];
         $options['source_field_options']['property_path'] = $sourceField;
     }
     $builder->add($formatField, 'choice', $options['format_field_options']);
     // If there's only one possible format, do not display the choices
     $formatChoices = $builder->get($formatField)->getOption('choices');
     if (count($formatChoices) === 1) {
         // Retrieve format value
         reset($formatChoices);
         // Ensure we're at the start
         $options['format_field_options']['data'] = key($formatChoices);
         // Remove the choice field
         unset($options['format_field_options']['choices']);
         $builder->remove($formatField);
         // Replace it with an hidden field
         $builder->add($formatField, 'hidden', $options['format_field_options']);
     }
     $builder->add($sourceField, 'textarea', $options['source_field_options']);
     /**
      * The listener option only work if the source field is after the current field
      */
     if ($options['listener']) {
         if (!$options['event_dispatcher'] instanceof EventDispatcherInterface) {
             throw new \RuntimeException('The event_dispatcher option must be an instance of EventDispatcherInterface');
         }
         $listener = new FormatterListener($this->pool, $options['format_field_options']['property_path'], $options['source_field_options']['property_path'], $options['target_field']);
         $options['event_dispatcher']->addListener(FormEvents::SUBMIT, array($listener, 'postSubmit'));
     }
 }
Ejemplo n.º 29
0
 public function buildForm(FormBuilderInterface $builder, array $options)
 {
     $builder->remove('current_password')->add('email', 'email', array('label' => 'Email'))->add('promo', null, array('label' => 'Promotion'))->add('phone', null, array('label' => 'Téléphone'));
 }
Ejemplo n.º 30
-6
 /**
  * {@inheritdoc}
  */
 public function buildForm(FormBuilderInterface $builder, array $options)
 {
     $builder->remove('expireAt');
     $builder->add('expireAt', 'payum_credit_card_expiration_date', ['widget' => 'single_text', 'input' => 'datetime', 'label' => 'form.credit_card.expire_at', 'html5' => false, 'format' => 'MM/yy/dd', 'attr' => ['placeholder' => 'mm/yy']]);
     $builder->get('expireAt')->addEventListener(FormEvents::PRE_SUBMIT, function (FormEvent $event) {
         $event->setData($event->getData() . '/01');
     });
 }