本文整理汇总了PHP中Symfony\Component\Form\FormBuilderInterface类的典型用法代码示例。如果您正苦于以下问题:PHP FormBuilderInterface类的具体用法?PHP FormBuilderInterface怎么用?PHP FormBuilderInterface使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了FormBuilderInterface类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: buildForm
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');
}
示例2: buildForm
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')));
}
示例3: buildForm
/**
* {@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'));
}
}
示例4: buildForm
public function buildForm(FormBuilderInterface $builder, array $options)
{
$transformer = new ManyRelatedTransformer($this->doctrineRegistry, $options['entityName']);
$viewTransformer = new ArrayToStringTransformer();
$builder->addModelTransformer($transformer);
$builder->addViewTransformer($viewTransformer);
}
示例5: buildForm
/**
* @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'));
}
示例6: buildForm
/**
* @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' => 'Заказать'));
}
示例7: buildForm
/**
* 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));
}
示例8: buildForm
/**
* {@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]);
}
示例9: buildForm
/**
* 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'));
}
示例10: buildForm
/**
* {@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());
}
}
示例11: buildForm
/**
* @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);
}
}
示例12: buildForm
/**
* {@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);
}
示例13: buildForm
/**
* 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));
}
示例14: buildForm
/**
* {@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());
}
示例15: DisableFieldSubscriber
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, []);
}