Author: Bernhard Schussek (bschussek@gmail.com)
Inheritance: extends Symfony\Component\Form\FormConfigBuilder, implements IteratorAggregate, implements Symfony\Component\Form\FormBuilderInterface
Beispiel #1
0
 public function buildForm(FormBuilder $builder, array $options)
 {
     if ($options['type'] === 'string') {
         $builder->appendNormTransformer(new ReversedTransformer(new FileToStringTransformer()));
     }
     $builder->appendNormTransformer(new FileToArrayTransformer())->add('file', 'field');
 }
Beispiel #2
0
 /**
  * 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');
     }
 }
Beispiel #3
0
 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());
 }
Beispiel #4
0
 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());
 }
 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'));
 }
Beispiel #6
0
 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');
 }
 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);
     }));
 }
Beispiel #8
0
 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());
 }
 public function buildForm(FormBuilder $builder, array $opciones)
 {
     $builder->add('nombreOpcion', 'text');
     $builder->add('descripcionOpcion', 'text');
     $builder->add('enlace', 'text');
     $builder->add('idOpcionSistema2', 'integer');
 }
 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));
             }
         }
     }
 }
Beispiel #11
0
 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 *'));
 }
Beispiel #12
0
 /**
  * {@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);
 }
 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";
 }
 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);
     }));
 }
 /**
  * {@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']);
 }
 public function buildForm(FormBuilder $builder, array $options)
 {
     $builder->add('lastname', 'text', array('label' => 'rtxlabs.user.label.lastname', 'required' => false));
     $builder->add('firstname', 'text', array('label' => 'rtxlabs.user.label.firstname', 'required' => false));
     $builder->add('username', 'text', array('label' => 'rtxlabs.user.label.username', 'required' => false));
     $builder->add('personnelNumber', 'text', array('label' => 'rtxlabs.user.label.personnel_number', 'required' => false));
 }
 public function buildForm(FormBuilder $builder, array $options)
 {
     $builder->add('name');
     $builder->add('email', 'email');
     $builder->add('subject');
     $builder->add('body', 'textarea');
 }
Beispiel #18
0
 public function buildForm(FormBuilder $builder, array $options)
 {
     $builder->add('account');
     $builder->add('user', 'entity', array('class' => 'Club\\UserBundle\\Entity\\User', 'required' => false));
     $builder->add('value');
     $builder->add('note');
 }
 public function buildForm(FormBuilder $builder, array $options)
 {
     $languages = $this->languages;
     unset($languages['en']);
     array_unshift($languages, 'Choose a language');
     $builder->add('code', 'choice', array('choices' => $languages))->add('author', 'text')->add('comment', 'text')->add('messagesValues', 'collection', array('type' => 'text'));
 }
Beispiel #20
0
 /**
  * {@inheritdoc}
  */
 public function buildForm(FormBuilder $builder, array $options)
 {
     // Overwrite required option for child fields
     $options['first_options']['required'] = $options['required'];
     $options['second_options']['required'] = $options['required'];
     $builder->appendClientTransformer(new ValueToDuplicatesTransformer(array($options['first_name'], $options['second_name'])))->add($options['first_name'], $options['type'], array_merge($options['options'], $options['first_options']))->add($options['second_name'], $options['type'], array_merge($options['options'], $options['second_options']));
 }
Beispiel #21
0
 public function buildForm(FormBuilder $builder, array $options)
 {
     $builder->add('senderEmail');
     $builder->add('senderName');
     $builder->add('subject');
     $builder->add('message', 'textarea');
 }
Beispiel #22
0
 public function buildForm(FormBuilder $builder, array $options)
 {
     // Only pass a subset of the options to children
     $dateOptions = array_intersect_key($options, array_flip(array('years', 'months', 'days')));
     $timeOptions = array_intersect_key($options, array_flip(array('hours', 'minutes', 'seconds', 'with_seconds')));
     if (isset($options['date_widget'])) {
         $dateOptions['widget'] = $options['date_widget'];
     }
     if (isset($options['date_format'])) {
         $dateOptions['format'] = $options['date_format'];
     }
     $dateOptions['input'] = 'array';
     if (isset($options['time_widget'])) {
         $timeOptions['widget'] = $options['time_widget'];
     }
     $timeOptions['input'] = 'array';
     $parts = array('year', 'month', 'day', 'hour', 'minute');
     $timeParts = array('hour', 'minute');
     if ($options['with_seconds']) {
         $parts[] = 'second';
         $timeParts[] = 'second';
     }
     $builder->appendClientTransformer(new DataTransformerChain(array(new DateTimeToArrayTransformer($options['data_timezone'], $options['user_timezone'], $parts), new ArrayToPartsTransformer(array('date' => array('year', 'month', 'day'), 'time' => $timeParts)))))->add('date', 'date', $dateOptions)->add('time', 'time', $timeOptions);
     if ($options['input'] === 'string') {
         $builder->appendNormTransformer(new ReversedTransformer(new DateTimeToStringTransformer($options['data_timezone'], $options['data_timezone'], 'Y-m-d H:i:s')));
     } else {
         if ($options['input'] === 'timestamp') {
             $builder->appendNormTransformer(new ReversedTransformer(new DateTimeToTimestampTransformer($options['data_timezone'], $options['data_timezone'])));
         } else {
             if ($options['input'] === 'array') {
                 $builder->appendNormTransformer(new ReversedTransformer(new DateTimeToArrayTransformer($options['data_timezone'], $options['data_timezone'], $parts)));
             }
         }
     }
 }
 public function buildForm(FormBuilder $builder, array $options)
 {
     $builder->add('defaultLanguage', 'choice', array('label' => 'Default language', 'choices' => array('de' => 'Deutsch', 'en' => "English")));
     $builder->add('defaultTheme', 'choice', array('choices' => array('basecamp' => 'Basecamp', 'modulaMartini' => 'Modula Martini', 'modulaMojito' => 'Modula Mojito'), 'label' => 'Default theme'));
     $builder->add('useGravatar', 'checkbox', array('label' => 'Use Gravatar user icons'));
     $builder->add('userFormat', 'choice', array('choices' => array('username' => 'jdoe', 'fullname_fl' => 'John Doe', 'fullname_lf' => 'Doe, John', 'firstname' => 'John', 'lastname' => 'Doe'), 'required' => true, 'label' => 'Userformat'));
 }
Beispiel #24
0
 function it_should_add_build_promotion_action_event_subscriber(FormBuilder $builder, FormFactoryInterface $factory)
 {
     $builder->getFormFactory()->willReturn($factory);
     $builder->add(Argument::any(), Argument::any(), Argument::any())->willReturn($builder);
     $builder->addEventSubscriber(Argument::type('Sylius\\Bundle\\PromotionBundle\\Form\\EventListener\\BuildActionFormListener'))->willReturn($builder);
     $this->buildForm($builder, array());
 }
	public function buildForm(FormBuilder $builder, array $options)
	{
		$builder->add('street');
		$builder->add('zipcode');
		$builder->add('city');
		$builder->add('country');
	}
 protected function getBuilder($name = 'name', $propertyPath = null)
 {
     $builder = new FormBuilder($name, $this->factory, $this->dispatcher);
     $builder->setAttribute('property_path', new PropertyPath($propertyPath ?: $name));
     $builder->setAttribute('error_mapping', array());
     return $builder;
 }
Beispiel #27
0
 public function buildForm(FormBuilder $builder, array $options)
 {
     $id = $this->options['user'];
     $builder->add('sede', 'entity', array('class' => 'dlaser\\ParametrizarBundle\\Entity\\Sede', 'property_path' => false, 'query_builder' => function (EntityRepository $er) use($id) {
         return $er->createQueryBuilder('s', 'u')->leftJoin("s.usuario", "u")->where("u.id = :id")->setParameter('id', $id);
     }))->add('paciente', 'integer', array('label' => 'Cedula Paciente:', 'required' => true, 'attr' => array('placeholder' => 'Ingrese la identificacion del paciente')))->add('cliente', 'choice', array('label' => 'Cliente:', 'choices' => array('' => '--')))->add('cargo', 'choice', array('label' => 'Cargo:', 'choices' => array('' => '--')))->add('agenda', 'choice', array('label' => 'Agenda asignar:', 'choices' => array('' => '--')))->add('hora', 'choice', array('label' => 'Hora agenda:', 'choices' => array('' => '--')))->add('nota', 'text', array('label' => 'Observaciones:', 'required' => false));
 }
Beispiel #28
0
    public function buildForm(FormBuilder $builder, array $options)
    {
        if (null === $options['property_path']) {
            $options['property_path'] = $builder->getName();
        }

        if (false === $options['property_path'] || '' === $options['property_path']) {
            $options['property_path'] = null;
        } else {
            $options['property_path'] = new PropertyPath($options['property_path']);
        }

        $builder->setRequired($options['required'])
            ->setReadOnly($options['read_only'])
            ->setErrorBubbling($options['error_bubbling'])
            ->setEmptyData($options['empty_data'])
            ->setAttribute('by_reference', $options['by_reference'])
            ->setAttribute('property_path', $options['property_path'])
            ->setAttribute('error_mapping', $options['error_mapping'])
            ->setAttribute('max_length', $options['max_length'])
            ->setAttribute('label', $options['label'] ?: $this->humanize($builder->getName()))
            ->setData($options['data'])
            ->addValidator(new DefaultValidator());

        if ($options['trim']) {
            $builder->addEventSubscriber(new TrimListener());
        }
    }
 public function let(Container $container, Translator $translator, Session $session, TopicRepository $topicRepository, EntityRepository $repository, EntityManager $entityManager, Request $request, FormFactory $formFactory, FormBuilder $formBuilder, Form $form, FormView $formView, Topic $topic, CsrfTokenManagerAdapter $csrfTokenManagerAdapter, AbstractQuery $query, AbstractQuery $query2, ParameterBag $parameterBag, ArticleTopicRepository $articleTopicrepository, UserService $userService, User $user, TopicService $topicService, Article $article, QueryBuilder $queryBuilder, CacheService $cacheService, EventDispatcher $dispatcher)
 {
     $container->get('em')->willReturn($entityManager);
     $container->get('session')->willReturn($session);
     $container->get('request')->willReturn($request);
     $container->get('translator')->willReturn($translator);
     $container->get('form.factory')->willReturn($formFactory);
     $container->get('form.csrf_provider')->willReturn($csrfTokenManagerAdapter);
     $container->get('newscoop.cache')->willReturn($cacheService);
     $container->get('user')->willReturn($userService);
     $container->get('dispatcher')->willReturn($dispatcher);
     $userService->getCurrentUser()->willReturn($user);
     $container->get('newscoop_newscoop.topic_service')->willReturn($topicService);
     $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);
     $entityManager->persist(Argument::any())->willReturn(true);
     $entityManager->flush(Argument::any())->willReturn(true);
     $entityManager->remove(Argument::any())->willReturn(true);
     $entityManager->getRepository('Newscoop\\NewscoopBundle\\Entity\\Topic')->willReturn($repository);
     $entityManager->getRepository('Newscoop\\Entity\\ArticleTopic')->willReturn($articleTopicrepository);
     $this->setContainer($container);
     $this->token = 'uTxRiEkont4XxRpTcSADPCowge7TgNONE7Y5HWd4pmY';
     $request->get('_csrf_token')->willReturn($this->token);
     $request->get('_code')->willReturn('en');
     $request->get('_articleNumber')->willReturn('64');
     $request->getLocale()->willReturn('en');
     $request->get('_code', 'en')->willReturn('en');
     $request->request = $parameterBag;
 }
 public function buildForm(FormBuilder $builder, array $options)
 {
     $builder->add('lastname', 'text', array('label' => 'Lastname', 'required' => false));
     $builder->add('firstname', 'text', array('label' => 'Firstname', 'required' => false));
     $builder->add('username', 'text', array('label' => 'Username', 'required' => false));
     $builder->add('group', 'entity', array('class' => 'CuteFlow\\CoreBundle\\Entity\\UserGroup', 'required' => false, 'label' => 'Usergroup'));
 }