本文整理汇总了PHP中Symfony\Component\Form\FormBuilderInterface::create方法的典型用法代码示例。如果您正苦于以下问题:PHP FormBuilderInterface::create方法的具体用法?PHP FormBuilderInterface::create怎么用?PHP FormBuilderInterface::create使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Symfony\Component\Form\FormBuilderInterface
的用法示例。
在下文中一共展示了FormBuilderInterface::create方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: buildForm
public function buildForm(FormBuilderInterface $builder, array $options)
{
$units = $options['units'];
// Options Headings
$headings = [];
foreach ($units as $unit) {
foreach ($unit->options as $name => $value) {
$headings[$name] = ucfirst($name);
}
}
foreach ($units as $unit) {
// If a unit has no options, it is broken so we should ignore it
if (count($unit->options) <= 0) {
continue;
}
$unitForm = $builder->create($unit->id, 'form');
$unitForm->add('sku', 'text', ['label' => false, 'data' => $unit->sku, 'attr' => ['placeholder' => 'ms.commerce.product.units.sku.placeholder']]);
// Create options form
$optionsForm = $builder->create('options', 'form');
foreach ($headings as $type => $displayName) {
$choices = [];
foreach ($this->_optionLoader->getByName($type) as $choice) {
$choice = trim($choice);
$choices[$choice] = $choice;
}
$fieldName = preg_replace('/[^a-z0-9]/i', '_', $type);
$optionsForm->add($fieldName, 'datalist', ['data' => !empty($unit->options[$type]) ? $unit->options[$type] : null, 'choices' => $choices]);
}
$unitForm->add($optionsForm);
$unitForm->add('prices', 'price_form', ['priced_entity' => $unit]);
$unitForm->add('weight', 'text', ['data' => $unit->weight !== $unit->getProduct()->weight ? $unit->weight : null, 'attr' => ['data-help-key' => 'ms.commerce.product.details.weight-grams.help']]);
$unitForm->add('visible', 'checkbox', ['data' => $unit->visible, 'attr' => ['data-help-key' => 'ms.commerce.product.units.visible.help']]);
$builder->add($unitForm);
}
}
示例2: buildForm
public function buildForm(FormBuilderInterface $builder, array $options)
{
$object = $builder->getData();
$tagTransformer = new TagsToTextTransformer($this->entityManager->getManager(), $this->taxonomyClass);
$photoTransformer = new PhotoToIdTransformer($this->entityManager->getManager());
$builder->add('title', 'text', array('required' => true, 'label' => 'Title:', 'attr' => array('class' => 'form-control form-control--lg margin--b', 'placeholder' => 'Enter title of the article')))->add('excerpt', 'textarea', array('required' => false, 'label' => 'Excerpt text:', 'attr' => array('class' => 'form-control form-control--lg margin--halfb', 'rows' => 2, 'placeholder' => 'Enter excerpt text')))->add($builder->create('excerptPhoto', 'hidden', array('attr' => array('class' => 'sr-only js-excerpt-photo'), 'required' => false))->addModelTransformer($photoTransformer))->add('content', 'textarea', array('required' => false, 'label' => ' ', 'attr' => array('class' => 'tinymce hide')))->add('categories', 'entity', array('class' => $this->taxonomyClass, 'required' => false, 'expanded' => true, 'multiple' => true, 'attr' => array('class' => 'js-get-pretty-categories', 'placeholder' => 'Select category')))->add($builder->create('tags', 'text', array('required' => false, 'attr' => array("class" => "form-control form-control--lg margin--halfb", "placeholder" => "Enter tags", "data-role" => "tagsinput")))->addModelTransformer($tagTransformer))->add('metaData', 'collection', array('type' => 'article_meta', 'allow_add' => true, 'allow_delete' => true, 'by_reference' => false))->add('metaExtras', 'hidden', array('mapped' => false));
if ($this->authorizationChecker->isGranted('SWITCH_ARTICLE_AUTHOR')) {
$builder->add('author', 'entity', array('label' => 'Author:', 'required' => true, 'class' => $this->userClass, 'placeholder' => 'Select author', 'query_builder' => function (EntityRepository $er) {
return $er->createQueryBuilder('a')->where('a.roles like :type')->orderBy('a.username', 'ASC')->setParameter('type', '%ROLE_BLOG_USER%');
}, 'attr' => array('class' => 'form-control form-control--lg color-placeholder')));
}
if ($this->authorizationChecker->isGranted('EDIT_PUBLISH_STATUS', $object)) {
$builder->add('status', 'choice', array('label' => 'Status:', 'choices' => array(Article::STATUS_PUBLISHED => "Published", Article::STATUS_DRAFTED => "Draft"), 'required' => true, 'attr' => array("class" => "form-control form-control--lg margin--halfb"), 'data' => $object->getParent() ? $object->getParent()->getStatus() : Article::STATUS_DRAFTED));
}
if (!$object->getParent()) {
//When creating new articles
if ($this->authorizationChecker->isGranted('PUBLISH_ARTICLE', $object)) {
$builder->add('publish', 'submit', array('attr' => array('class' => 'btn btn-md btn-primary btn-wide--xl flright--responsive-mob margin--b first-in-line js-publish-article')));
}
$builder->add('save_draft', 'submit', array('attr' => array('class' => 'btn btn-md btn-b-blue btn-wide--xl flright--responsive-mob margin--r')));
} else {
if ($object && $object->getParent() && $object->getParent()->getStatus() == Article::STATUS_DRAFTED) {
$builder->add('save', 'submit', array('attr' => array('class' => 'btn btn-md btn-b-blue btn-wide--xl flright--responsive-mob margin--r')));
if ($this->authorizationChecker->isGranted('PUBLISH_ARTICLE', $object)) {
$builder->add('publish', 'submit', array('attr' => array('class' => 'btn btn-md btn-primary btn-wide--xl flright--responsive-mob margin--b first-in-line js-publish-article')));
}
} else {
$builder->add('update', 'submit', array('attr' => array('class' => 'btn btn-md btn-primary btn-wide--xl flright--responsive-mob margin--r')));
}
}
}
示例3: buildForm
public function buildForm(FormBuilderInterface $builder, array $options)
{
// assuming $entityManager is passed in options
$em = $options['em'];
$transformer = new OrganisationunitToIdTransformer($em);
$builder->add($builder->create('organisationunit', 'hidden', array('constraints' => array(new NotBlank())))->addModelTransformer($transformer))->add($builder->create('organisationunitToMove', 'hidden', array('required' => true, 'constraints' => array(new NotBlank())))->addModelTransformer($transformer))->add($builder->create('parentOrganisationunit', 'hidden', array('required' => true, 'constraints' => array(new NotBlank())))->addModelTransformer($transformer))->add('submit', 'submit');
}
示例4: buildForm
public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder->add($builder->create('dtAcaoInicio', 'text', array('label' => '', 'required' => false))->addModelTransformer(new CxDatePtBrTransformer()));
$builder->add($builder->create('dtAcaoFim', 'text', array('label' => '', 'required' => false))->addModelTransformer(new CxDatePtBrTransformer()));
$builder->add('idLocal', 'entity', array('class' => 'CacicCommonBundle:Local', 'property' => 'sgLocal', 'multiple' => true, 'required' => true, 'expanded' => true, 'label' => 'Selecione o Local:'));
$builder->add('usuario', null, array('label' => '', 'max_length' => 30, 'required' => true));
}
示例5: buildForm
public function buildForm(FormBuilderInterface $builder, array $options)
{
// Fix, so the url gets parsed thought twig
$twig = clone $this->app['twig'];
$twig->setLoader(new \Twig_Loader_String());
// Participant
/*
* Show only the first time until the visitor isn't a participant yet.
* Each time afer that, the participant will automaticall be "attached"
* to the entry.
*/
if (!$this->app['participant']) {
$nameData = null;
$emailData = null;
if ($this->app['facebookUser']) {
$nameData = isset($this->app['facebookUser']->name) ? $this->app['facebookUser']->name : null;
$emailData = isset($this->app['facebookUser']->email) ? $this->app['facebookUser']->email : null;
}
$builder->add($builder->create('participant', 'form', array('label' => false, 'by_reference' => true, 'data_class' => 'Application\\Entity\\ParticipantEntity'))->add('name', 'text', array('data' => $nameData))->add('email', 'email', array('data' => $emailData)));
}
// Entry
$builder->add($builder->create('entry', 'form', array('label' => false, 'by_reference' => true, 'data_class' => 'Application\\Entity\\EntryEntity'))->add($builder->create('metas', 'form', array('label' => false))->add('answer', 'text', array('label' => 'What is the meaning of life?'))->add('me_and_the_hulk_image', 'file', array('label' => 'An image of yourself an the Hulk!', 'constraints' => array(new \Symfony\Component\Validator\Constraints\Image())))));
$builder->add('terms', 'checkbox', array('label' => $twig->render('You agree with our <a href="{{ url(\'application.terms\') }}" target="_blank">Terms</a>'), 'required' => true));
$builder->add('submit', 'submit', array('label' => 'Submit', 'attr' => array('class' => 'btn-primary btn-lg btn-block')));
}
示例6: buildForm
/**
* Builds a form with given fields.
*
* @param object $builder A Formbuilder interface object
* @param array $options An array of options
*/
public function buildForm(FormBuilderInterface $builder, array $options)
{
$entityManager = $options['em'];
$transformer = new UserIdToObjectTransformer($entityManager);
$userAcOptions = array();
// Disable employee form if access is not granted
// Currently access is only granted for ROLE_ADMIN.
if ($options['data']->getUser() instanceof \Opit\OpitHrm\UserBundle\Entity\User) {
if (false === $this->isGranted) {
$userAcOptions['disabled'] = true;
}
}
$builder->add($builder->create('user', 'hidden')->addModelTransformer($transformer));
$builder->add('user_ac', 'text', array_merge(array('label' => 'Employee name', 'data' => ($user = $options['data']->getUser()) ? $user->getEmployee()->getEmployeeNameFormatted() : null, 'mapped' => false, 'attr' => array('placeholder' => 'Employee name', 'class' => 'width-300')), $userAcOptions));
$builder->add('departure_date', 'date', array('widget' => 'single_text', 'label' => 'Departure date', 'attr' => array('placeholder' => 'Departure date')));
$builder->add('arrival_date', 'date', array('widget' => 'single_text', 'label' => 'Arrival date', 'attr' => array('placeholder' => 'Arrival date')));
$builder->add('customer_related', 'choice', array('required' => false, 'empty_value' => false, 'data' => 'No', 'label' => 'Customer related', 'choices' => array('1' => 'No', '0' => 'Yes')));
$builder->add('customer_name', 'text', array('label' => 'Customer name', 'required' => false, 'attr' => array('placeholder' => 'Customer name')));
$builder->add('trip_purpose', 'text', array('label' => 'Trip purpose', 'attr' => array('placeholder' => 'Trip purpose', 'class' => 'width-300')));
$builder->add('destinations', 'collection', array('type' => new DestinationType(), 'allow_add' => true, 'allow_delete' => true, 'by_reference' => false));
$builder->add('accomodations', 'collection', array('type' => new AccomodationType($entityManager), 'allow_add' => true, 'allow_delete' => true, 'by_reference' => false));
$builder->add($builder->create('team_manager', 'hidden')->addModelTransformer($transformer));
$builder->add('team_manager_ac', 'text', array('label' => 'Team manager', 'data' => ($user = $options['data']->getTeamManager()) ? $user->getEmployee()->getEmployeeNameFormatted() : null, 'mapped' => false, 'required' => false, 'attr' => array('placeholder' => 'Team manager', 'class' => 'width-300')));
$builder->add($builder->create('general_manager', 'hidden')->addModelTransformer($transformer));
$builder->add('general_manager_ac', 'text', array('label' => 'General manager', 'data' => ($user = $options['data']->getGeneralManager()) ? $user->getEmployee()->getEmployeeNameFormatted() : null, 'mapped' => false, 'attr' => array('placeholder' => 'General manager', 'class' => 'width-300')));
$builder->add('add_travel_request', 'submit', array('label' => $this->isNew ? 'Edit travel request' : 'Add travel request', 'attr' => array('class' => 'button')));
}
示例7: buildForm
public function buildForm(FormBuilderInterface $builder, array $options)
{
$regionFrom = $options['regionFrom'];
$regionTo = $options['regionTo'];
$floatTransformer = new FloatTransformer();
$builder->add('securityCompany', 'entity', array('class' => 'AppTruckingBundle:SecurityCompany', 'query_builder' => function ($repository) {
return $repository->createQueryBuilder('p')->orderBy('p.id', 'ASC');
}, 'property' => 'name', 'empty_data' => '', 'empty_value' => 'Select', 'attr' => array('class' => 'form-control')));
$builder->add('securityType', 'entity', array('class' => 'AppTruckingBundle:SecurityType', 'query_builder' => function ($repository) {
return $repository->createQueryBuilder('p')->orderBy('p.id', 'ASC');
}, 'empty_data' => '', 'empty_value' => 'Select', 'property' => 'name', 'attr' => array('class' => 'form-control')));
$builder->add('regionFrom', 'entity', array('class' => 'CoreBundle:Region', 'query_builder' => function ($repository) {
return $repository->createQueryBuilder('p')->orderBy('p.id', 'ASC');
}, 'empty_data' => '', 'empty_value' => 'Select', 'required' => true, 'property' => 'nameRu', 'attr' => array('class' => 'col-md-12')));
$builder->add('cityFrom', 'entity', array('class' => 'CoreBundle:City', 'query_builder' => function ($repository) use($regionFrom) {
return $repository->createQueryBuilder('p')->where('p.regionId = :region')->setParameter('region', $regionFrom)->orderBy('p.id', 'ASC');
}, 'empty_data' => '', 'empty_value' => 'Select', 'required' => true, 'property' => 'nameRu', 'attr' => array('class' => 'col-md-12')));
$builder->add('regionTo', 'entity', array('class' => 'CoreBundle:Region', 'query_builder' => function ($repository) {
return $repository->createQueryBuilder('p')->orderBy('p.id', 'ASC');
}, 'empty_data' => '', 'empty_value' => 'Select', 'required' => true, 'property' => 'nameRu', 'attr' => array('class' => 'selectpicker col-md-12')));
$builder->add('cityTo', 'entity', array('class' => 'CoreBundle:City', 'query_builder' => function ($repository) use($regionTo) {
return $repository->createQueryBuilder('p')->where('p.regionId = :region')->setParameter('region', $regionTo)->orderBy('p.id', 'ASC');
}, 'empty_data' => '', 'empty_value' => 'Select', 'required' => true, 'property' => 'nameRu', 'attr' => array('class' => 'col-md-12')));
$builder->add('minWorkTime', 'text', array('label' => 'Min.working time'));
$builder->add($builder->create('cost', 'text')->addModelTransformer($floatTransformer));
$builder->add('addHour', 'text', array('label' => 'Additional hours'));
$builder->add($builder->create('costAdd', 'text', array('label' => 'Additional cost'))->addModelTransformer($floatTransformer));
}
示例8: renderFormField
public function renderFormField(FormBuilderInterface &$builder, $callback = NULL, $prefix = NULL)
{
$fields = array();
$skip_eq = [self::TYPE_DATETIME, self::TYPE_ARRAY];
if (!in_array($this->getType(), $skip_eq)) {
$fields[] = $builder->create($this->getRangedFieldName(self::RANGE_START, $prefix), 'choice', array('label' => false, 'choices' => $this->getSearchOperators()->toArray(), 'data' => $this->getSearchOperators()->getDefaultSelected(), 'attr' => array('data-prefix' => $prefix, 'data-range-type' => self::RANGE_START, 'data-range-title' => $this->getFieldName())));
}
switch ($this->getType()) {
case self::TYPE_STRING:
$fields[] = $builder->create($this->getRangedFieldName(self::RANGE_END, $prefix), 'text', array('attr' => array('data-prefix' => $prefix, 'data-range-type' => self::RANGE_END), 'required' => false));
break;
case self::TYPE_INTEGER:
$fields[] = $builder->create($this->getRangedFieldName(self::RANGE_END, $prefix), 'integer', array('attr' => array('data-prefix' => $prefix, 'data-range-type' => self::RANGE_END), 'required' => false));
break;
case self::TYPE_DECIMAL:
$fields[] = $builder->create($this->getRangedFieldName(self::RANGE_END, $prefix), 'number', array('attr' => array('data-prefix' => $prefix, 'data-range-type' => self::RANGE_END), 'required' => false));
break;
/**
* CUSTOM FIELDS
*/
/**
* CUSTOM FIELDS
*/
case self::TYPE_ARRAY:
// dont add
break;
case self::TYPE_DATETIME:
$fields[] = $builder->create($this->getRangedFieldName(self::RANGE_START, $prefix), 'datetime', array('format' => 'dd.MM.yyyy H:mm', 'widget' => 'single_text', 'attr' => array('data-prefix' => $prefix, 'data-range-type' => self::RANGE_START, 'data-range-title' => $this->getFieldName(), 'placeholder' => self::RANGE_START, 'class' => 'bs-datetimepicker', 'data-format' => 'DD.MM.YYYY H:mm'), 'required' => false));
$fields[] = $builder->create($this->getRangedFieldName(self::RANGE_END, $prefix), 'datetime', array('format' => 'dd.MM.yyyy H:mm', 'widget' => 'single_text', 'attr' => array('data-prefix' => $prefix, 'data-range-type' => self::RANGE_END, 'placeholder' => self::RANGE_END, 'class' => 'bs-datetimepicker', 'data-format' => 'DD.MM.YYYY H:mm'), 'required' => false));
break;
}
if (count($fields) > 0 && is_callable($callback)) {
call_user_func($callback, $fields, $builder);
}
}
示例9: buildForm
/**
* {@inheritdoc}
*/
public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder->addEventSubscriber($this->subscriber);
$builder->add('autocomplete', 'oro_tag_autocomplete');
$builder->add($builder->create('all', 'hidden')->addViewTransformer($this->transformer));
$builder->add($builder->create('owner', 'hidden')->addViewTransformer($this->transformer));
}
示例10: buildForm
/**
* {@inheritdoc}
*/
public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder->add('page_url', 'text', ['label' => 'mautic.page.point.action.form.page.url', 'label_attr' => ['class' => 'control-label'], 'attr' => ['class' => 'form-control', 'tooltip' => 'mautic.page.point.action.form.page.url.descr', 'placeholder' => 'http://']]);
// $default = (isset($options['data']) && isset($options['data']['first_time'])) ? $options['data']['first_time'] : false;
// $builder->add('first_time', 'yesno_button_group', array(
// 'label' => 'mautic.page.point.action.form.first.time.only',
// 'attr' => array(
// 'tooltip' => 'mautic.page.point.action.form.first.time.only.descr'
// ),
// 'data' => $default
// ));
$builder->add('page_hits', 'integer', ['label' => 'mautic.page.hits', 'label_attr' => ['class' => 'control-label'], 'required' => false, 'attr' => ['class' => 'form-control', 'tooltip' => 'mautic.page.point.action.form.page.hits.descr']]);
$formModifier = function (FormInterface $form, $data) use($builder) {
$unit = isset($data['accumulative_time_unit']) ? $data['accumulative_time_unit'] : 'H';
$form->add('accumulative_time_unit', 'hidden', ['data' => $unit]);
$secondsTransformer = new SecondsConversionTransformer($unit);
$form->add($builder->create('accumulative_time', 'text', ['label' => 'mautic.page.point.action.form.accumulative.time', 'required' => false, 'label_attr' => ['class' => 'control-label'], 'attr' => ['class' => 'form-control', 'tooltip' => 'mautic.page.point.action.form.accumulative.time.descr'], 'auto_initialize' => false])->addViewTransformer($secondsTransformer)->getForm());
$unit = isset($data['returns_within_unit']) ? $data['returns_within_unit'] : 'H';
$secondsTransformer = new SecondsConversionTransformer($unit);
$form->add('returns_within_unit', 'hidden', ['data' => $unit]);
$form->add($builder->create('returns_within', 'text', ['label' => 'mautic.page.point.action.form.returns.within', 'required' => false, 'label_attr' => ['class' => 'control-label'], 'attr' => ['class' => 'form-control', 'tooltip' => 'mautic.page.point.action.form.returns.within.descr', 'onBlur' => 'Mautic.EnablesOption(this.id)'], 'auto_initialize' => false])->addViewTransformer($secondsTransformer)->getForm());
$unit = isset($data['returns_after_unit']) ? $data['returns_after_unit'] : 'H';
$secondsTransformer = new SecondsConversionTransformer($unit);
$form->add('returns_after_unit', 'hidden', ['data' => $unit]);
$form->add($builder->create('returns_after', 'text', ['label' => 'mautic.page.point.action.form.returns.after', 'required' => false, 'label_attr' => ['class' => 'control-label'], 'attr' => ['class' => 'form-control', 'tooltip' => 'mautic.page.point.action.form.returns.after.descr', 'onBlur' => 'Mautic.EnablesOption(this.id)'], 'auto_initialize' => false])->addViewTransformer($secondsTransformer)->getForm());
};
$builder->addEventListener(FormEvents::PRE_SET_DATA, function (FormEvent $event) use($formModifier) {
$data = $event->getData();
$formModifier($event->getForm(), $data);
});
$builder->addEventListener(FormEvents::PRE_SUBMIT, function (FormEvent $event) use($formModifier) {
$data = $event->getData();
$formModifier($event->getForm(), $data);
});
}
示例11: buildForm
/**
* {@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);
}
示例12: buildForm
/**
* {@inheritdoc}
*/
public function buildForm(FormBuilderInterface $builder, array $options)
{
$config = $this->config;
$builder->add('company_name', 'text', array('label' => '会社名', 'required' => false, 'constraints' => array(new Assert\Length(array('max' => $config['stext_len'])))))->add('shop_name', 'text', array('label' => '店名', 'required' => true, 'constraints' => array(new Assert\NotBlank(), new Assert\Length(array('max' => $config['stext_len'])))))->add('shop_name_eng', 'text', array('label' => '店名(英語表記)', 'required' => false, 'constraints' => array(new Assert\Length(array('max' => $config['mtext_len'])), new Assert\Regex(array('pattern' => '/^[[:graph:][:space:]]+$/i')))))->add('zip', 'zip', array('required' => false))->add('address', 'address', array('required' => false))->add('tel', 'tel', array('required' => false))->add('fax', 'tel', array('required' => false))->add('business_hour', 'text', array('label' => '店舗営業時間', 'required' => false, 'constraints' => array(new Assert\Length(array('max' => $config['stext_len'])))))->add('email01', 'email', array('label' => '送信元メールアドレス(From)', 'required' => false, 'constraints' => array(new Assert\NotBlank(), new Assert\Email(array('strict' => true)))))->add('email02', 'email', array('label' => '問い合わせ受付メールアドレス(From, ReplyTo)', 'required' => false, 'constraints' => array(new Assert\NotBlank(), new Assert\Email(array('strict' => true)))))->add('email03', 'email', array('label' => '返信受付メールアドレス(ReplyTo)', 'required' => false, 'constraints' => array(new Assert\NotBlank(), new Assert\Email(array('strict' => true)))))->add('email04', 'email', array('label' => '送信エラー受付メールアドレス(ReturnPath)', 'required' => false, 'constraints' => array(new Assert\NotBlank(), new Assert\Email(array('strict' => true)))))->add('good_traded', 'textarea', array('label' => '取り扱い商品', 'required' => false, 'constraints' => array(new Assert\Length(array('max' => $config['lltext_len'])))))->add('message', 'textarea', array('label' => 'メッセージ', 'required' => false, 'constraints' => array(new Assert\Length(array('max' => $config['lltext_len'])))))->add('delivery_free_amount', 'money', array('label' => '送料無料条件(金額)', 'required' => false, 'currency' => 'JPY', 'precision' => 0, 'constraints' => array(new Assert\Length(array('max' => $config['price_len'])), new Assert\Regex(array('pattern' => "/^\\d+\$/u", 'message' => 'form.type.numeric.invalid')))))->add('delivery_free_quantity', 'integer', array('label' => '送料無料条件(数量)', 'required' => false, 'constraints' => array(new Assert\Regex(array('pattern' => "/^\\d+\$/u", 'message' => 'form.type.numeric.invalid')))))->add('option_product_delivery_fee', 'choice', array('label' => '商品ごとの送料設定を有効にする', 'choices' => array('0' => '無効', '1' => '有効'), 'expanded' => true, 'multiple' => false))->add('option_multiple_shipping', 'choice', array('label' => '複数配送を有効にする', 'choices' => array('0' => '無効', '1' => '有効'), 'expanded' => true, 'multiple' => false))->add('option_customer_activate', 'choice', array('label' => '仮会員を有効にする', 'choices' => array('0' => '無効', '1' => '有効'), 'expanded' => true, 'multiple' => false))->add('option_mypage_order_status_display', 'choice', array('label' => 'マイページに注文状況を表示する', 'choices' => array('0' => '無効', '1' => '有効'), 'expanded' => true, 'multiple' => false))->add('option_remember_me', 'choice', array('label' => '自動ログイン機能を有効にする', 'choices' => array('0' => '無効', '1' => '有効'), 'expanded' => true, 'multiple' => false))->add('option_favorite_product', 'choice', array('label' => 'お気に入り商品機能を利用する', 'choices' => array('0' => '無効', '1' => '有効'), 'expanded' => true, 'multiple' => false))->add('nostock_hidden', 'choice', array('label' => '在庫切れ商品を非表示にする', 'choices' => array('0' => '無効', '1' => '有効'), 'expanded' => true, 'multiple' => false))->add('latitude', 'number', array('label' => '緯度', 'required' => false, 'precision' => 6, 'constraints' => array(new Assert\Regex(array('pattern' => '/^-?([0-8]?[0-9]\\.?[0-9]{0,6}|90\\.?0{0,6})$/', 'message' => 'admin.shop.latitude.invalid')))))->add('longitude', 'number', array('label' => '経度', 'required' => false, 'precision' => 6, 'constraints' => array(new Assert\Regex(array('pattern' => '/^-?((1?[0-7]?|[0-9]?)[0-9]\\.?[0-9]{0,6}|180\\.?0{0,6})$/', 'message' => 'admin.shop.longitude.invalid')))));
$builder->add($builder->create('company_kana', 'text', array('label' => '会社名(フリガナ)', 'required' => false, 'constraints' => array(new Assert\Regex(array('pattern' => "/^[ァ-ヶヲ-゚ー]+\$/u")), new Assert\Length(array('max' => $config['stext_len'])))))->addEventSubscriber(new \Eccube\EventListener\ConvertKanaListener('CV')));
$builder->add($builder->create('shop_kana', 'text', array('label' => '店名(フリガナ)', 'required' => false, 'constraints' => array(new Assert\Length(array('max' => $config['stext_len'])), new Assert\Regex(array('pattern' => "/^[ァ-ヶヲ-゚ー]+\$/u")))))->addEventSubscriber(new \Eccube\EventListener\ConvertKanaListener('CV')));
}
示例13: createTab
/**
* Create a new tab and nest it under the tabs.
*
* @param string $name
* @param string $label
* @param array $options
*
* @return FormBuilderInterface The created tab.
*/
public function createTab($name, $label, $options = array())
{
$options = array_replace($options, array('label' => $label, 'inherit_data' => true));
$tab = $this->formBuilder->create($name, TabsTabType::class, $options);
$this->formBuilder->get('tabs')->add($tab);
return $tab;
}
示例14: buildForm
public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder->add('name', 'textarea', array('label' => 'ddi.lead_actions.tasks.thead.name', 'label_attr' => array('class' => 'control-label'), 'attr' => array('class' => 'nomousetrap form-control', 'rows' => 10), 'constraints' => array(new NotBlank(array('message' => 'ddi.lead_actions.task.name.notblank')))));
// Campaign builder form
if (!empty($options['type'])) {
$data = empty($options['data']['dateInterval']) ? 1 : $options['data']['dateInterval'];
$builder->add('dateInterval', 'number', array('label' => 'ddi.lead_actions.tasks.form.due_date_after', 'attr' => array('class' => 'form-control', 'preaddon' => 'symbol-hashtag'), 'data' => $data));
$data = !empty($options['data']['dateIntervalUnit']) ? $options['data']['dateIntervalUnit'] : 'd';
$builder->add('dateIntervalUnit', 'choice', array('choices' => array('i' => 'mautic.campaign.event.intervalunit.choice.i', 'h' => 'mautic.campaign.event.intervalunit.choice.h', 'd' => 'mautic.campaign.event.intervalunit.choice.d', 'm' => 'mautic.campaign.event.intervalunit.choice.m', 'y' => 'mautic.campaign.event.intervalunit.choice.y'), 'multiple' => false, 'label_attr' => array('class' => 'control-label'), 'label' => false, 'attr' => array('class' => 'form-control'), 'empty_value' => false, 'required' => false, 'data' => $data));
// Default form
} else {
$dueDate = $builder->create('dueDate', 'datetime', array('widget' => 'single_text', 'label' => 'ddi.lead_actions.tasks.thead.due_date', 'label_attr' => array('class' => 'control-label'), 'attr' => array('class' => 'nomousetrap form-control', 'data-toggle' => 'datetime', 'preaddon' => 'fa fa-calendar'), 'format' => 'yyyy-MM-dd HH:mm', 'required' => true, 'constraints' => array(new NotBlank(array('message' => 'ddi.lead_actions.task.due_date.notblank')))));
$builder->add($dueDate);
$builder->add('buttons', 'form_buttons', array('apply_text' => false, 'save_text' => 'mautic.core.form.save'));
}
$assignUser = $builder->create('assignUser', 'user_list', array('label' => 'ddi.lead_actions.tasks.thead.assigned_user', 'label_attr' => array('class' => 'control-label, required'), 'attr' => array('class' => 'nomousetrap form-control'), 'required' => false, 'multiple' => false, 'constraints' => array(new NotBlank(array('message' => 'ddi.lead_actions.task.assigned_user.notblank')))));
if (empty($options['type'])) {
$transformer = new IdToEntityModelTransformer($this->factory->getEntityManager(), 'MauticUserBundle:User');
$assignUser->addModelTransformer($transformer);
}
$builder->add($assignUser);
if (!empty($options['action'])) {
$builder->setAction($options['action']);
}
}
示例15: buildForm
/**
* @param FormBuilderInterface $builder
* @param array $options
*/
public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder->addEventSubscriber(new CleanFormSubscriber(['content' => 'html']));
$builder->addEventSubscriber(new FormExitSubscriber('dynamicContent.dynamicContent', $options));
$builder->add('name', 'text', ['label' => 'mautic.dynamicContent.form.internal.name', 'label_attr' => ['class' => 'control-label'], 'attr' => ['class' => 'form-control']]);
$emojiTransformer = new EmojiToShortTransformer();
$builder->add($builder->create('description', 'textarea', ['label' => 'mautic.dynamicContent.description', 'label_attr' => ['class' => 'control-label'], 'attr' => ['class' => 'form-control'], 'required' => false])->addModelTransformer($emojiTransformer));
$builder->add('isPublished', 'yesno_button_group');
$builder->add('language', 'locale', ['label' => 'mautic.core.language', 'label_attr' => ['class' => 'control-label'], 'attr' => ['class' => 'form-control'], 'required' => false]);
$builder->add('publishUp', 'datetime', ['widget' => 'single_text', 'label' => 'mautic.core.form.publishup', 'label_attr' => ['class' => 'control-label'], 'attr' => ['class' => 'form-control', 'data-toggle' => 'datetime'], 'format' => 'yyyy-MM-dd HH:mm', 'required' => false]);
$builder->add('publishDown', 'datetime', ['widget' => 'single_text', 'label' => 'mautic.core.form.publishdown', 'label_attr' => ['class' => 'control-label'], 'attr' => ['class' => 'form-control', 'data-toggle' => 'datetime'], 'format' => 'yyyy-MM-dd HH:mm', 'required' => false]);
$builder->add('content', 'textarea', ['label' => 'mautic.dynamicContent.form.content', 'label_attr' => ['class' => 'control-label'], 'attr' => ['tooltip' => 'mautic.dynamicContent.form.content.help', 'class' => 'form-control editor editor-advanced editor-builder-tokens', 'rows' => '15'], 'required' => false]);
$transformer = new IdToEntityModelTransformer($this->em, 'MauticDynamicContentBundle:DynamicContent');
$builder->add($builder->create('translationParent', 'dwc_list', ['label' => 'mautic.core.form.translation_parent', 'label_attr' => ['class' => 'control-label'], 'attr' => ['class' => 'form-control', 'tooltip' => 'mautic.core.form.translation_parent.help'], 'required' => false, 'multiple' => false, 'empty_value' => 'mautic.core.form.translation_parent.empty', 'top_level' => 'translation', 'ignore_ids' => [(int) $options['data']->getId()]])->addModelTransformer($transformer));
$builder->add('category', 'category', ['bundle' => 'dynamicContent']);
if (!empty($options['update_select'])) {
$builder->add('buttons', 'form_buttons', ['apply_text' => false]);
$builder->add('updateSelect', 'hidden', ['data' => $options['update_select'], 'mapped' => false]);
} else {
$builder->add('buttons', 'form_buttons');
}
if (!empty($options['action'])) {
$builder->setAction($options['action']);
}
}