php Symfony-Component-Form-FormBuilderInterface类(方法)实例源码

下面列出了php Symfony-Component-Form-FormBuilderInterface 类(方法)源码代码实例,从而了解它的用法。

作者:pitoukhme    项目:protal   
public function buildForm(FormBuilderInterface $builder, array $options)
 {
     $builder->add('author', 'text');
     $builder->add('email', 'email');
     $builder->add('website', 'url', array('required' => false));
     $builder->add('content', 'textarea');
 }

作者:yoannfleuryde    项目:amicale-sr   
public function buildForm(FormBuilderInterface $builder, array $options)
 {
     $builder->add('tags', TextType::class, array('label' => false, 'constraints' => array(new Length(array('min' => 2, 'max' => 50))), 'attr' => array('class' => 'form-control')));
     $builder->add('filter', ChoiceType::class, array('choices' => array('Tout' => 'all', 'Forum' => 'forum', 'Offres' => 'offer', 'Evenements' => 'hall', 'Profils' => 'profile'), 'choices_as_values' => true, 'expanded' => true, 'multiple' => false));
     $builder->add('method', ChoiceType::class, array('choices' => array('ET' => 'and', 'OU' => 'or'), 'choices_as_values' => true, 'expanded' => true, 'multiple' => false));
     $builder->add('no', TextType::class, array('label' => false, 'required' => false, 'constraints' => array(new Length(array('min' => 2, 'max' => 50))), 'attr' => array('class' => 'form-control')));
 }

作者:bendavie    项目:LexikMailerBundl   
/**
  * {@inheritdoc}
  */
 public function buildForm(FormBuilderInterface $builder, array $options)
 {
     $builder->add('body', null, array('attr' => array('rows' => 20), 'label' => 'lexik_mailer.translations.subject'));
     if ($options['with_language']) {
         $builder->add('lang', 'language', array('preferred_choices' => $options['preferred_languages'], 'label' => 'lexik_mailer.translations.subject'));
     }
 }

作者:profca    项目:ilio   
public function buildForm(FormBuilderInterface $builder, array $options)
 {
     $transformer = new ManyRelatedTransformer($this->doctrineRegistry, $options['entityName']);
     $viewTransformer = new ArrayToStringTransformer();
     $builder->addModelTransformer($transformer);
     $builder->addViewTransformer($viewTransformer);
 }

作者:binaryfr3a    项目:sfitix   
/**
  * @param FormBuilderInterface $builder
  * @param array $options
  */
 public function buildForm(FormBuilderInterface $builder, array $options)
 {
     $builder->add('id', 'hidden');
     $builder->add('name', 'text', array('label' => 'bankholiday.field.name'));
     $builder->add('date', 'datePicker', array('label' => 'bankholiday.field.date'));
     $builder->add('memo', 'textarea', array('required' => false, 'label' => 'bankholiday.field.memo'));
 }

作者:novusco    项目:cmfbundl   
/**
  * @param FormBuilderInterface $builder
  * @param array $options
  */
 public function buildForm(FormBuilderInterface $builder, array $options)
 {
     $builder->add('address', TextType::class, array('label' => 'Адрес доставки'));
     $builder->add('phone', TextType::class, array('label' => 'Телефон'));
     $builder->add('name', TextType::class, array('label' => 'ФИО'));
     $builder->add('submit', SubmitType::class, array('label' => 'Заказать'));
 }

作者:baki    项目:KunstmaanBundlesCM   
/**
  * Builds the form.
  *
  * This method is called for each type in the hierarchy starting form the
  * top most type. Type extensions can further modify the form.
  *
  * @param FormBuilderInterface $builder The form builder
  * @param array $options The options
  *
  * @see FormTypeExtensionInterface::buildForm()
  *
  * @return void
  */
 public function buildForm(FormBuilderInterface $builder, array $options)
 {
     $folder = $options['folder'];
     $builder->add('name', null, array('label' => 'media.folder.addsub.form.name'))->add('rel', ChoiceType::class, array('choices' => array('media' => 'media', 'image' => 'image', 'slideshow' => 'slideshow', 'video' => 'video'), 'choices_as_values' => true, 'label' => 'media.folder.addsub.form.rel'))->add('parent', EntityType::class, array('class' => 'KunstmaanMediaBundle:Folder', 'choice_label' => 'optionLabel', 'label' => 'media.folder.addsub.form.parent', 'required' => true, 'query_builder' => function (FolderRepository $er) use($folder) {
         return $er->selectFolderQueryBuilder($folder);
     }))->add('internalName', TextType::class, array('label' => 'media.folder.addsub.form.internal_name', 'required' => false));
 }

作者:DeFreita    项目:raphael.de-freitas.ne   
/**
  * {@inheritdoc}
  */
 public function buildForm(FormBuilderInterface $builder, array $options)
 {
     $builder->add('email', EmailType::class, ['required' => true]);
     $builder->add('subject', TextType::class, ['required' => true]);
     $builder->add('content', TextareaType::class, ['required' => true]);
     $builder->add('captcha', CaptchaType::class, ['required' => true]);
 }

作者:Kunstmaa    项目:KunstmaanLeadGenerationBundl   
/**
  * Builds the form.
  *
  * This method is called for each type in the hierarchy starting form the
  * top most type. Type extensions can further modify the form.
  *
  * @see FormTypeExtensionInterface::buildForm()
  *
  * @param FormBuilderInterface $builder The form builder
  * @param array $options The options
  */
 public function buildForm(FormBuilderInterface $builder, array $options)
 {
     $builder->add('days', IntegerType::class, array('label' => 'kuma_lead_generation.form.recurring_every_x_time.days.label', 'required' => false));
     $builder->add('hours', IntegerType::class, array('label' => 'kuma_lead_generation.form.recurring_every_x_time.hours.label', 'required' => false));
     $builder->add('minutes', IntegerType::class, array('label' => 'kuma_lead_generation.form.recurring_every_x_time.minutes.label', 'required' => false));
     $builder->add('times', IntegerType::class, array('label' => 'kuma_lead_generation.form.recurring_every_x_time.times.label'));
 }

作者:nfabr    项目:symfon   
/**
  * {@inheritdoc}
  */
 public function buildForm(FormBuilderInterface $builder, array $options)
 {
     $builder->setRequired($options['required'])->setDisabled($options['disabled'])->setErrorBubbling($options['error_bubbling'])->setEmptyData($options['empty_data'])->setPropertyPath($options['property_path'])->setMapped($options['mapped'])->setByReference($options['by_reference'])->setVirtual($options['virtual'])->setCompound($options['compound'])->setData(isset($options['data']) ? $options['data'] : null)->setDataLocked(isset($options['data']))->setDataMapper($options['compound'] ? new PropertyPathMapper($this->propertyAccessor) : null);
     if ($options['trim']) {
         $builder->addEventSubscriber(new TrimListener());
     }
 }

作者:clasti    项目:clasti   
/**
  * @param FormBuilderInterface $builder
  * @param array                $options
  */
 public function buildForm(FormBuilderInterface $builder, array $options)
 {
     $type = $builder->getData()->getNode()->getType();
     if (isset($this->nodeExtensions[$type])) {
         $this->nodeExtensions[$type]->buildForm($builder, $options);
     }
 }

作者:smart8    项目:UnifikDoctrineBehaviorsBundl   
/**
  * {@inheritdoc}
  */
 public function buildForm(FormBuilderInterface $builder, array $options)
 {
     $builder->addModelTransformer($this->denormalizedEntityTransformer);
     $this->tagManager->setLocale($options['locale']);
     // On Pre-Submit, create the news posted Tags otherwise the form won't be valid
     $builder->addEventListener(FormEvents::PRE_SUBMIT, function ($event) use($options) {
         // Data when posted
         $tags = $event->getData();
         $entity = $event->getForm()->getParent()->getData();
         // Loop through the posted tags (if not numeric, it's a news Tag)
         if (is_array($tags)) {
             foreach ($tags as $key => $tagId) {
                 if (!is_numeric($tagId)) {
                     $tag = $this->tagManager->loadOrCreateTag($tagId, $options['use_global_tags'] ? null : $entity->getResourceType());
                     $tags[$key] = $tag->getId();
                     $entity->setTagsUpdatedAt(new \DateTime());
                 }
             }
             // Update the posted data with the newly created tags
             $event->setData($tags);
             $this->taggableListener->setNeedToFlush(true);
         } elseif (null === $tags && count($entity->getTags())) {
             // All tags are removed
             $this->taggableListener->setNeedToFlush(true);
         }
     }, 900);
 }

作者:Kyra277    项目:AM   
/**
  * 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->addEventSubscriber(new CsrfValidationListener($options['csrf_field_name'], $options['csrf_token_manager'], $options['csrf_token_id'] ?: ($builder->getName() ?: get_class($builder->getType()->getInnerType())), $options['csrf_message'], $this->translator, $this->translationDomain));
 }

作者:hiroyasu5    项目:ec-cub   
/**
  * {@inheritdoc}
  */
 public function buildForm(FormBuilderInterface $builder, array $options)
 {
     $deliveries = $options['deliveries'];
     $delivery = $options['delivery'];
     $deliveryDates = $options['deliveryDates'];
     $builder->add('delivery', 'entity', array('class' => 'Eccube\\Entity\\Delivery', 'property' => 'name', 'choices' => $deliveries, 'data' => $delivery))->add('deliveryDate', 'choice', array('choices' => $deliveryDates, 'required' => false, 'empty_value' => '指定なし'))->add('deliveryTime', 'entity', array('class' => 'Eccube\\Entity\\DeliveryTime', 'property' => 'deliveryTime', 'choices' => $delivery->getDeliveryTimes(), 'required' => false, 'empty_value' => '指定なし', 'empty_data' => null))->addEventSubscriber(new \Eccube\Event\FormEventSubscriber());
 }

作者:ashutosh-srija    项目:findit_akene   
function it_builds_form(FormBuilderInterface $builder)
 {
     $builder->add('code')->shouldBeCalled();
     $builder->addEventSubscriber(new DisableFieldSubscriber('code'))->shouldBeCalled();
     $builder->add('label', 'pim_translatable_field', ['field' => 'label', 'translation_class' => 'Pim\\Bundle\\CatalogBundle\\Entity\\AssociationTypeTranslation', 'entity_class' => 'Pim\\Bundle\\CatalogBundle\\Entity\\AssociationType', 'property_path' => 'translations'])->shouldBeCalled();
     $this->buildForm($builder, []);
 }

作者:jeboeh    项目:lampc   
/**
  * Determine, if form is in editing mode
  *
  * @param \Symfony\Component\Form\FormBuilderInterface $builder
  *
  * @return bool
  */
 protected function _getIsEditMode(FormBuilderInterface $builder)
 {
     if (!$builder->getData()->getId()) {
         return false;
     }
     return true;
 }

作者:hacklab    项目:login-cidada   
/**
  * @param FormBuilderInterface $builder
  * @param array $options
  */
 public function buildForm(FormBuilderInterface $builder, array $options)
 {
     $person = $this->person;
     $clientId = $this->clientId;
     $receiversConfig = array('label' => 'Receivers', 'ajax_choice_attr' => array('filter' => array('route' => 'lc_dev_broadcasts_grid_receivers_filter', 'search_prop' => 'username', 'extra_form_prop' => array('client_id' => 'client_id')), 'selected' => array('route' => 'lc_dev_broadcasts_grid_receivers', 'extra_form_prop' => array('person_id' => 'receivers', 'client_id' => 'client_id')), 'property_value' => 'id', 'property_text' => 'fullNameOrUsername', 'search_prop_label' => 'dev.broadcasts.receivers.filter'), 'required' => true, 'empty_data' => null, 'class' => 'PROCERGSLoginCidadaoCoreBundle:Person', 'property' => 'fullNameOrUsername');
     $builder->add('category', 'entity', array('required' => true, 'empty_data' => null, 'class' => 'PROCERGS\\LoginCidadao\\NotificationBundle\\Entity\\Category', 'property' => 'name', 'query_builder' => function (CategoryRepository $repository) use($person, $clientId) {
         return $repository->getOwnedCategoriesQuery($person)->andWhere('c.id = :clientId')->setParameter('clientId', $clientId);
     }));
     $builder->add('client_id', 'hidden', array('required' => false, 'mapped' => false, 'data' => $clientId));
     $builder->addEventListener(FormEvents::PRE_SUBMIT, function (FormEvent $event) use(&$receiversConfig, &$person, $clientId) {
         $entity = $event->getData();
         $form = $event->getForm();
         $receiversConfig['query_builder'] = function (PersonRepository $repository) use($clientId, &$entity) {
             $sql = $repository->getFindAuthorizedByClientIdQuery($clientId);
             if (!empty($entity['receivers'])) {
                 $sql->andWhere('p.id in (:receivers)');
                 $sql->setParameter('receivers', $entity['receivers']);
             }
             return $sql;
         };
         $form->add('receivers', 'ajax_choice', $receiversConfig);
     });
     $builder->addEventListener(FormEvents::PRE_SET_DATA, function (FormEvent $event) use(&$receiversConfig, &$person, &$clientId) {
         $entity = $event->getData();
         $form = $event->getForm();
         $receiversConfig['query_builder'] = function (PersonRepository $repository) {
             $sql = $repository->createQueryBuilder('u');
             $sql->where('1 != 1');
             return $sql;
         };
         $form->add('receivers', 'ajax_choice', $receiversConfig);
     });
 }

作者:luisbrit    项目:Phraseane   
public function buildForm(FormBuilderInterface $builder, array $options)
 {
     $builder->add('name', 'text', ['label' => 'Task name', 'required' => true, 'constraints' => [new Assert\NotBlank()]]);
     $builder->add('period', 'integer', ['label' => 'Task period (in seconds)', 'required' => true, 'constraints' => [new Assert\NotBlank(), new Assert\GreaterThan(['value' => 0])]]);
     $builder->add('status', 'choice', ['label' => 'The task status', 'choices' => [Task::STATUS_STARTED => 'Started', Task::STATUS_STOPPED => 'Stopped']]);
     $builder->add('settings', 'hidden');
 }

作者:eric19    项目:turbulent-wooki   
/**
  * @param \Symfony\Component\Form\FormBuilderInterface $builder
  * @param array $options
  * @author Eric Haynes
  */
 public function buildForm(FormBuilderInterface $builder, array $options)
 {
     $site = $this->site;
     $application = $this->application;
     $builder->add('sale_price', 'money', array('label' => 'Sale Price', 'currency' => 'USD', 'required' => true, 'precision' => 2, 'grouping' => true, 'attr' => array('class' => 'span2')))->add('loan_amount', 'money', array('label' => 'Loan Amount', 'currency' => 'USD', 'required' => true, 'precision' => 2, 'grouping' => true, 'attr' => array('class' => 'span2')))->add('loan_term', 'number', array('label' => 'Term (Years)', 'required' => true, 'attr' => array('class' => 'span1', 'maxlength' => 2)))->add('loan_type', 'choice', array('choices' => $application->loanTypes, 'empty_value' => 'Please select one'))->add('loan_purpose', 'choice', array('label' => 'Which type of loan are you applying for?', 'multiple' => false, 'choices' => $application->loanPurposes, 'expanded' => true, 'multiple' => false))->add('status', 'choice', array('label' => 'Loan Status', 'choices' => $application->loanStatuses))->add('num_units', 'number', array('label' => 'Number of Units', 'required' => true, 'attr' => array('class' => 'span1')))->add('property_type', 'choice', array('choices' => $application->propertyTypes, 'empty_value' => 'Please select one'))->add('property_year_built', 'text', array('label' => 'Year Built', 'required' => false, 'attr' => array('class' => 'span2', 'maxlength' => 4)))->add('residency_type', 'choice', array('choices' => $application->residencyTypes, 'empty_value' => 'Please select one'))->add('title_company1', 'text', array('label' => 'Name #1', 'required' => false))->add('title_company2', 'text', array('label' => 'Name #2', 'required' => false))->add('has_realtor', 'choice', array('label' => 'Are you currently working with a Realtor?', 'choices' => array(0 => 'No', 1 => 'Yes'), 'multiple' => false, 'expanded' => true))->add('is_lennar_home', 'choice', array('label' => 'Is this a lennar home?', 'choices' => array(false => 'No', true => 'Yes'), 'multiple' => false, 'expanded' => true))->add('lennar_community_name', 'text', array('label' => 'Community Name?', 'required' => false))->add('lennar_builder_name', 'text', array('label' => 'Builder Name?', 'required' => false))->add('need_to_sell', 'choice', array('required' => false, 'label' => 'Do you need to sell home?', 'choices' => array(1 => 'Yes', 2 => 'No'), 'multiple' => false, 'expanded' => true))->add('property_location', new PropertyLocationType($site), array('validation_groups' => array('step2')))->add('realtor_name', 'text', array('attr' => array('class' => 'realtor-info-field')))->add('realtor_company', 'text', array('attr' => array('class' => 'realtor-info-field')))->add('realtor_phone', 'text', array('attr' => array('class' => 'realtor-info-field phonenumber')))->add('borrower', new EagleBorrowerType())->add('co_borrower', 'collection', array('type' => new EagleBorrowerType(), 'allow_add' => true, 'allow_delete' => true, 'prototype' => true, 'by_reference' => false))->add('asset_account', 'collection', array('type' => new EagleAssetAccountType($this->application->getId()), 'allow_add' => true, 'allow_delete' => true, 'prototype' => true, 'by_reference' => false))->add('asset_real_estate', 'collection', array('type' => new EagleAssetRealEstateType($this->application->getId()), 'allow_add' => true, 'allow_delete' => true, 'prototype' => true, 'by_reference' => false))->add('income_other', 'collection', array('type' => new EagleIncomeOtherType($this->application->getId()), 'allow_add' => true, 'allow_delete' => true, 'prototype' => true, 'by_reference' => false))->add('income_monthly', 'collection', array('type' => new EagleIncomeMonthlyType($this->application->getId()), 'allow_add' => true, 'allow_delete' => true, 'prototype' => true, 'by_reference' => false))->add('agreement_one', 'checkbox', array('required' => true))->add('agreement_two', 'checkbox', array('required' => true))->add('agreement_three', 'checkbox', array('required' => true))->add('expense_housing', new ExpenseHousingType())->add('comments', 'textarea', array('attr' => array('class' => 'span3'), 'required' => false))->add('loan_officer', 'entity', array('label' => 'Are you working with a loan officer?', 'class' => 'SudouxMortgageBundle:LoanOfficer', 'property' => 'fullname', 'multiple' => false, 'empty_value' => 'Select a loan officer', 'required' => false, 'query_builder' => function (EntityRepository $er) use($site) {
         return $er->findAllBySiteType($site);
     }))->add('refinance_year_acquired', 'number', array('label' => 'Year Acquired', 'required' => true, 'attr' => array('class' => 'span1', 'maxlength' => 4)))->add('refinance_original_cost', 'money', array('label' => 'Original Cost', 'currency' => 'USD', 'required' => true, 'precision' => 2, 'grouping' => true, 'attr' => array('class' => 'span2')))->add('refinance_existing_liens', 'money', array('label' => 'Existing Liens', 'currency' => 'USD', 'required' => true, 'precision' => 2, 'grouping' => true, 'attr' => array('class' => 'span2')))->add('refinance_current_rate', 'text', array('label' => 'Current Rate', 'required' => true, 'attr' => array('class' => 'span1')))->add('refinance_current_loan_type', 'text', array('label' => 'Current Loan Type', 'required' => true, 'attr' => array('class' => 'span3')))->add('refinance_current_lender', 'text', array('label' => 'Current Lender', 'required' => true, 'attr' => array('class' => 'span3')))->add('refinance_purpose', 'choice', array('label' => 'Purpose of Refinance', 'choices' => $application->refinancePurposes, 'required' => true, 'empty_value' => 'Please select one'))->add('referral_source', 'entity', array('class' => 'Sudoux\\Cms\\FormBundle\\Entity\\ReferralSource', 'property' => 'name', 'required' => false, 'multiple' => true, 'expanded' => true, 'label' => 'Where did you hear about us?', 'attr' => array('class' => 'checkbox-group'), 'query_builder' => function (EntityRepository $er) use($site) {
         return $er->findAllActiveBySiteQuery($site);
     }))->add('no_property_location', 'checkbox', array('label' => 'I do not have a property yet', 'attr' => array('class' => ''), 'required' => false));
     $titleManner = $this->application->getTitleManner();
     if (isset($titleManner)) {
         $builder->add('title_manner', 'text', array('label' => 'Manner', 'required' => false));
     } else {
         $builder->add('title_manner', 'choice', array('label' => 'Manner', 'required' => false, 'choices' => $application->titleManners, 'empty_value' => 'Please select one', 'required' => false));
     }
     /*$group = $application->getMilestoneGroup();
             if(isset($group)) {
     			$builder->add('milestone', 'entity', array(
     				'label' => 'Loan Status',
     				'class' => 'SudouxMortgageBundle:LoanMilestone',
     				'property' => 'name',
     				'multiple' => false,
     				'empty_value' => 'Select a status',
     				'required' => false,
     				'query_builder' => function(EntityRepository $er) use ($group) {
     					return $er->findByMilestoneGroupQuery($group->getId());
     				}
     			));
     		}*/
 }

作者:ramunas    项目:platfor   
/**
  * {@inheritdoc}
  */
 public function buildForm(FormBuilderInterface $builder, array $options)
 {
     $builder->add('label', 'text', array('required' => true, 'label' => 'oro.dashboard.label'));
     if ($options['create_new']) {
         $builder->add('startDashboard', 'oro_dashboard_select', array('required' => false, 'label' => 'oro.dashboard.start_dashboard'));
     }
 }


问题


面经


文章

微信
公众号

扫码关注公众号