本文整理汇总了PHP中Symfony\Component\Form\FormBuilder类的典型用法代码示例。如果您正苦于以下问题:PHP FormBuilder类的具体用法?PHP FormBuilder怎么用?PHP FormBuilder使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了FormBuilder类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: buildForm
public function buildForm(FormBuilder $builder, array $options)
{
if ($options['type'] === 'string') {
$builder->appendNormTransformer(new ReversedTransformer(new FileToStringTransformer()));
}
$builder->appendNormTransformer(new FileToArrayTransformer())->add('file', 'field');
}
示例2: buildForm
/**
* Configures a Comment form.
*
* @param FormBuilder $builder
* @param array $options
*/
public function buildForm(FormBuilder $builder, array $options)
{
$builder->add('message', 'textarea');
if (!$this->securityContext->isGranted('IS_AUTHENTICATED_REMEMBERED')) {
$builder->add('authorName', 'text');
}
}
示例3: array
function it_should_add_rule_event_subscriber(FormBuilder $builder, FormFactoryInterface $factory)
{
$builder->getFormFactory()->willReturn($factory);
$builder->add(Argument::any(), Argument::cetera())->willReturn($builder);
$builder->addEventSubscriber(Argument::type(BuildRuleFormSubscriber::class))->willReturn($builder);
$this->buildForm($builder, array());
}
示例4: array
function it_builds_form_with_proper_fields(FormBuilder $builder, FormFactoryInterface $factory)
{
$builder->getFormFactory()->willReturn($factory);
$builder->addEventSubscriber(Argument::type('Sylius\\Bundle\\TaxonomyBundle\\Form\\EventListener\\BuildTaxonFormSubscriber'))->willReturn($builder);
$builder->add('translations', 'a2lix_translationsForms', Argument::any())->willReturn($builder);
$this->buildForm($builder, array());
}
示例5: buildForm
public function buildForm(FormBuilder $builder, array $options)
{
$builder->add('firstname', 'text', array('label' => 'form.label.firstname'))->add('lastname', 'text', array('label' => 'form.label.lastname'))->add('states', 'choice', array('choices' => array('foo' => 'bar'), 'empty_value' => 'form.states.empty_value'))->add('countries', 'choice', array('empty_value' => false))->add('password', 'repeated', array('first_options' => array('label' => 'form.label.password'), 'second_options' => array('label' => 'form.label.password_repeated'), 'invalid_message' => 'form.error.password_mismatch'))->add('street', 'text', array('label' => 'form.label.street', 'translation_domain' => 'address'))->add('zip', 'text', array('label' => 'form.label.zip', 'translation_domain' => 'address'))->add('field_with_placeholder', 'text', array('label' => 'field.with.placeholder', 'attr' => array('placeholder' => 'form.placeholder.text')))->add('field_without_label', 'text', array('label' => false, 'attr' => array('placeholder' => 'form.placeholder.text.but.no.label')));
$child = $builder->create('created', 'text', array('label' => 'form.label.created'));
$builder->add('dueDate', 'date', array('empty_value' => array('year' => 'form.dueDate.empty.year', 'month' => 'form.dueDate.empty.month', 'day' => 'form.dueDate.empty.day')));
$builder->add('field_with_ignored_label', 'text', array('label' => 'form.ignored'));
}
示例6: buildForm
public function buildForm(FormBuilder $builder, array $options)
{
if ($options['type'] === 'string') {
$builder->appendNormTransformer(new ReversedTransformer(new FileToStringTransformer()));
}
$builder->appendNormTransformer(new FileToArrayTransformer())->addEventSubscriber(new FixFileUploadListener($this->storage), 10)->add('file', 'field')->add('token', 'hidden')->add('name', 'hidden')->add('originalName', 'hidden');
}
示例7: buildForm
public function buildForm(FormBuilder $builder, array $options)
{
$id = $this->options['user'];
$builder->add('sede', 'entity', array('class' => 'dlaser\\ParametrizarBundle\\Entity\\Sede', 'property_path' => false, 'empty_value' => 'Seleccione una sede', 'query_builder' => function (EntityRepository $er) use($id) {
return $er->createQueryBuilder('s', 'u')->leftJoin("s.usuario", "u")->where("u.id = :id")->setParameter('id', $id);
}));
}
示例8: array
function it_should_add_rule_event_subscriber(FormBuilder $builder, FormFactoryInterface $factory)
{
$builder->getFormFactory()->willReturn($factory);
$builder->add(Argument::any(), Argument::cetera())->willReturn($builder);
$builder->addEventSubscriber(Argument::type('Sylius\\Bundle\\ShippingBundle\\Form\\EventListener\\BuildRuleFormSubscriber'))->willReturn($builder);
$this->buildForm($builder, array());
}
示例9: buildForm
public function buildForm(FormBuilder $builder, array $opciones)
{
$builder->add('nombreOpcion', 'text');
$builder->add('descripcionOpcion', 'text');
$builder->add('enlace', 'text');
$builder->add('idOpcionSistema2', 'integer');
}
示例10: translationFormClb
protected function translationFormClb($action, $row, \Symfony\Component\Form\FormBuilder $form)
{
if (count($this->translationFields)) {
$langs = $this->get('nyrocms')->getLocaleNames($row);
$defaultLocale = $this->get('nyrocms')->getDefaultLocale($row);
unset($langs[$defaultLocale]);
$this->translations = array();
foreach ($row->getTranslations() as $tr) {
if (!isset($this->translations[$tr->getLocale()])) {
$this->translations[$tr->getLocale()] = array();
}
$this->translations[$tr->getLocale()][$tr->getField()] = $tr;
}
/* @var $form \Ivory\OrderedForm\Builder\OrderedFormBuilder */
$propertyAccess = PropertyAccess::createPropertyAccessor();
foreach ($langs as $lg => $lang) {
foreach ($this->translationFields as $field => $options) {
$type = $options['type'];
unset($options['type']);
$fieldName = 'lang_' . $lg . '_' . $field;
if (isset($options['required']) && $options['required']) {
$options['constraints'] = array(new Constraints\NotBlank());
}
$form->add($fieldName, $type, array_merge(array('label' => $this->trans('admin.' . $this->translationPrefix . '.' . $field) . ' ' . strtoupper($lg), 'mapped' => false, 'data' => isset($this->translations[$lg]) && isset($this->translations[$lg][$field]) ? $this->translations[$lg][$field]->getContent() : $propertyAccess->getValue($row, $field), 'position' => array('after' => $field)), $options));
}
}
}
}
示例11: buildForm
public function buildForm(FormBuilder $builder, array $options)
{
$id = $this->options['cie'];
$builder->add('fecha', 'datetime', array('read_only' => true))->add('cie', 'entity', array('class' => 'dlaser\\HcBundle\\Entity\\Cie', 'query_builder' => function (EntityRepository $er) use($id) {
return $er->createQueryBuilder('c', 'hc')->leftJoin("c.hc", "hc")->where("hc.id = :id")->setParameter('id', $id);
}))->add('resumen_hc', 'textarea', array('label' => 'Resumen HC'))->add('pos_utilizado', 'text', array('required' => false, 'label' => 'Pos utilizado'))->add('pos_dosis', 'integer', array('required' => false, 'label' => 'Pos dosis'))->add('pos_tiempo', 'integer', array('required' => false, 'label' => 'Pos tiempo'))->add('pos_posologia', 'text', array('required' => false, 'label' => 'Pos posologia'))->add('pos_respuesta', 'textarea', array('required' => false, 'label' => 'Pos respuesta'))->add('nopos_nota', 'textarea', array('label' => 'Justificación No POS *'))->add('nopos_efectos', 'textarea', array('label' => 'Efectos Adversos del No POS *'));
}
示例12: buildForm
/**
* {@inheritdoc}
*/
public function buildForm(FormBuilder $builder, array $options)
{
$configs = array_replace($this->options, $options['configs']);
$sizeLimit = 2;
$fileDesc = '';
$fileExt = '';
$fileMeta = new Upload();
if (true === isset($configs['multi']) && $configs['multi']) {
$options['multiple'] = true;
}
if (true === $options['multiple']) {
$configs['multi'] = true;
}
if (!isset($options['sizeLimit'])) {
$max_upload = (int) ini_get('upload_max_filesize');
$sizeLimit = $max_upload * 1000000;
} else {
$sizeLimit = $options['sizeLimit'];
}
if (!isset($options['fileDesc'])) {
$fileDesc = 'Tous les fichiers';
} else {
$fileDesc = $options['fileDesc'];
}
if (!isset($options['fileExt'])) {
$fileExt = '*.*';
} else {
$fileExt = $options['fileExt'];
}
$builder->addEventSubscriber(new FileListener($this->rootDir, $options['multiple'], $this->em))->setAttribute('configs', $configs)->setAttribute('rootDir', $this->rootDir)->setAttribute('multiple', $options['multiple'])->setAttribute('session', $this->session)->setAttribute('fileDesc', $fileDesc)->setAttribute('fileExt', $fileExt)->setAttribute('sizeLimit', $sizeLimit)->setAttribute('fileMeta', $fileMeta);
}
示例13: let
public function let(ArticleService $articleService, AuthorService $authorService, CacheService $cacheService, Container $container, ArticleRepository $articleRepository, LanguageRepository $languageRepository, ArticleTypeRepository $articleTypeRepository, PublicationRepository $publicationRepository, IssueRepository $issueRepository, SectionRepository $sectionRepository, AuthorTypeRepository $authorTypeRepository, EntityManager $entityManager, Request $request, FormFactory $formFactory, FormBuilder $formBuilder, Form $form, FormView $formView, User $user, UserService $userService, Article $article, Publication $publication, ArticleType $articleType, Issue $issue, Section $section, Language $language, Author $author, AuthorType $authorType, AbstractQuery $query, SecurityContext $security, TokenInterface $token, Router $router)
{
$container->get('em')->willReturn($entityManager);
$container->get('request')->willReturn($request);
$container->get('user')->willReturn($userService);
$container->get('form.factory')->willReturn($formFactory);
$container->get('newscoop_newscoop.article_service')->willReturn($articleService);
$container->get('author')->willReturn($authorService);
$container->get('newscoop.cache')->willReturn($cacheService);
$container->get('router')->willReturn($router);
$formBuilder->getForm(Argument::cetera())->willReturn($form);
$formFactory->create(Argument::cetera())->willReturn($form);
$form->createView()->willReturn($formView);
$form->handleRequest(Argument::cetera())->willReturn(true);
$form->isValid()->willReturn(true);
$security->getToken()->willReturn($token);
$container->get('security.context')->willReturn($security);
$container->has('security.context')->willReturn(true);
$this->setContainer($container);
$entityManager->getRepository('Newscoop\\Entity\\Article')->willReturn($articleRepository);
$entityManager->getRepository('Newscoop\\Entity\\Language')->willReturn($languageRepository);
$entityManager->getRepository('Newscoop\\Entity\\ArticleType')->willReturn($articleTypeRepository);
$entityManager->getRepository('Newscoop\\Entity\\Publication')->willReturn($publicationRepository);
$entityManager->getRepository('Newscoop\\Entity\\Issue')->willReturn($issueRepository);
$entityManager->getRepository('Newscoop\\Entity\\Section')->willReturn($sectionRepository);
$entityManager->getRepository('Newscoop\\Entity\\AuthorType')->willReturn($authorTypeRepository);
$articleRepository->getArticle(Argument::cetera())->willReturn($query);
$entityManager->flush(Argument::any())->willReturn(true);
$userService->getCurrentUser()->willReturn($user);
$number = 64;
$language = "en";
}
示例14: buildForm
public function buildForm(FormBuilder $builder, array $options)
{
if (!isset($options['currency'])) {
throw new \InvalidArgumentException(sprintf('The option "currency" must be given for form type "%s".', $this->getName()));
}
if (!isset($options['amount'])) {
throw new \InvalidArgumentException(sprintf('The option "amount" must be given for form type "%s".', $this->getName()));
}
$allowAllMethods = !isset($options['allowed_methods']);
$options['available_methods'] = array();
foreach ($this->paymentMethods as $method) {
if (!$allowAllMethods && !in_array($method, $options['allowed_methods'], true)) {
continue;
}
$options['available_methods'][] = $method;
}
if (!$options['available_methods']) {
throw new \RuntimeException(sprintf('You have not selected any payment methods. Available methods: "%s"', implode(', ', $this->paymentMethods)));
}
$builder->add('method', 'choice', array('choices' => $this->buildChoices($options['available_methods']), 'expanded' => true));
foreach ($options['available_methods'] as $method) {
$methodOptions = isset($options['method_options'][$method]) ? $options['method_options'] : array();
$builder->add('data_' . $method, $method, $methodOptions);
}
$self = $this;
$builder->addValidator(new CallbackValidator(function ($form) use($self, $options) {
$self->validate($form, $options);
}));
$builder->appendNormTransformer(new CallbackTransformer(function ($data) use($self, $options) {
return $self->transform($data, $options);
}, function ($data) use($self, $options) {
return $self->reverseTransform($data, $options);
}));
}
示例15: buildForm
/**
* {@inheritdoc}
*/
public function buildForm(FormBuilder $builder, array $options)
{
if (!$options['choice_list']) {
$options['choice_list'] = new AjaxArrayChoiceList($options['choices'], $options['ajax']);
}
$builder->appendClientTransformer(new ChoiceToJsonTransformer($options['choice_list'], $options['widget'], $options['multiple'], $options['ajax'], $options['freeValues']))->setAttribute('choice_list', $options['choice_list'])->setAttribute('widget', $options['widget'])->setAttribute('route_name', $options['route_name'])->setAttribute('freeValues', $options['freeValues']);
}