コード例 #1
0
 public function buildForm(FormBuilderInterface $builder, array $options)
 {
     $builder->setAttribute('base_path', $options['base_path']);
     $builder->setAttribute('css_path', $options['css_path']);
     $builder->setAttribute('js_path', $options['js_path']);
     $builder->setAttribute('config', $options['config']);
 }
コード例 #2
0
 /**
  * {@inheritdoc}
  */
 public function buildForm(FormBuilderInterface $builder, array $options)
 {
     $builder->addViewTransformer(new ModelToIdTransformer($options['model_manager'], $options['class']), true);
     $builder->setAttribute('root_node', $options['root_node']);
     $builder->setAttribute('select_root_node', $options['select_root_node']);
     $builder->setAttribute('repository_name', $options['repository_name']);
 }
 /**
  * @param FormBuilderInterface $builder
  * @param array                $options
  */
 public function buildForm(FormBuilderInterface $builder, array $options)
 {
     $builder->setAttribute('group_enabled', $options['group_enabled']);
     $builder->setAttribute('group_id', $options['group_id']);
     $builder->setAttribute('sub_group_id', $options['sub_group_id']);
     $builder->setAttribute('group_render', $options['group_render']);
     $builder->setAttribute('sub_group_render', $options['sub_group_render']);
 }
コード例 #4
0
 /**
  * {@inheritdoc}
  */
 public function buildForm(FormBuilderInterface $builder, array $options)
 {
     $builder->setAttribute('enable', $options['enable']);
     if ($builder->getAttribute('enable')) {
         $builder->setAttribute('instance', $options['instance']);
     }
     $builder->setAttribute('homeFolder', $options['homeFolder']);
 }
コード例 #5
0
 public function buildForm(FormBuilderInterface $builder, array $options)
 {
     if (!empty($options['invalid_message'])) {
         $builder->setAttribute('invalid_message', $options['invalid_message']);
     }
     if (!empty($options['invalid_message_parameters'])) {
         $builder->setAttribute('invalid_message_parameters', $options['invalid_message_parameters']);
     }
 }
コード例 #6
0
 /**
  * {@inheritdoc}
  */
 public function buildForm(FormBuilderInterface $builder, array $options)
 {
     if (null !== $options['apply_filter']) {
         $builder->setAttribute('apply_filter', $options['apply_filter']);
     }
     if ($options['filter_condition_builder'] instanceof \Closure) {
         $builder->setAttribute('filter_condition_builder', $options['filter_condition_builder']);
     }
 }
コード例 #7
0
 /**
  * {@inheritdoc}
  */
 public function buildForm(FormBuilderInterface $builder, array $options)
 {
     if ($options['apply_filter'] instanceof \Closure || is_callable($options['apply_filter']) || is_string($options['apply_filter'])) {
         $builder->setAttribute('apply_filter', $options['apply_filter']);
     }
     if ($options['filter_condition_builder'] instanceof \Closure) {
         $builder->setAttribute('filter_condition_builder', $options['filter_condition_builder']);
     }
 }
コード例 #8
0
 /**
  * {@inheritdoc}
  */
 public function buildForm(FormBuilderInterface $builder, array $options)
 {
     $builder->setAttribute('enable', $options['enable']);
     if ($builder->getAttribute('enable')) {
         $builder->setAttribute('base_path', $options['base_path']);
         $builder->setAttribute('js_path', $options['js_path']);
         $builder->setAttribute('inline', $options['inline']);
         $builder->setAttribute('instance', $options['instance']);
     }
 }
コード例 #9
0
 public function buildForm(FormBuilderInterface $builder, array $options)
 {
     if (null === $options['class']) {
         throw new InvalidConfigurationException('Option "class" is empty');
     }
     if (null === $options['parent_field']) {
         throw new InvalidConfigurationException('Option "parent_field" is empty');
     }
     if (null === $options['property']) {
         throw new InvalidConfigurationException('Option "property" is empty');
     }
     $builder->addViewTransformer(new EntityToIdTransformer($this->em, $options['class']), true);
     $query = $options['query'];
     if ($query instanceof \Closure) {
         $queryBuilder = $query($this->em->getRepository($options['class']));
         $query = $queryBuilder->getQuery()->getDql();
     }
     $builder->setAttribute('class', $options['class']);
     $builder->setAttribute("parent_field", $options['parent_field']);
     $builder->setAttribute("no_result_msg", $options['no_result_msg']);
     $builder->setAttribute("empty_value", $options['empty_value']);
     $builder->setAttribute("property", $options['property']);
     $builder->setAttribute("em_name", $options['em_name']);
     $builder->setAttribute('query', $query);
     $builder->setAttribute("order_direction", $options['order_direction']);
     $builder->setAttribute("order_property", $options['order_property']);
 }
コード例 #10
0
ファイル: CollectionCustomType.php プロジェクト: blab2015/seh
 /**
  * {@inheritdoc}
  */
 public function buildForm(FormBuilderInterface $builder, array $options)
 {
     if ($options['allow_add'] && $options['prototype']) {
         $prototype = $builder->create($options['prototype_name'], $options['type'], array_replace(array('label' => $options['prototype_name'] . 'label__'), $options['options']));
         $builder->setAttribute('prototype', $prototype->getForm());
     }
     if ($options['class_container']) {
         $builder->setAttribute('class_container', $options['class_container']);
     }
     $resizeListener = new ResizeFormListener($options['type'], $options['options'], $options['allow_add'], $options['class_container'], $options['allow_delete']);
     $builder->addEventSubscriber($resizeListener);
 }
コード例 #11
0
 /**
  * @param FormBuilderInterface $builder
  * @param array                $options
  */
 public function buildForm(FormBuilderInterface $builder, array $options)
 {
     $builder->add('label', 'text', array('label' => 'open_orchestra_backoffice.form.block.label', 'constraints' => new NotBlank(), 'group_id' => 'property', 'sub_group_id' => 'property'));
     $builder->add('style', 'choice', array('label' => 'open_orchestra_backoffice.form.block.style', 'required' => false, 'choices' => $this->getStyleChoices(), 'group_id' => 'property', 'sub_group_id' => 'style'));
     $builder->add('maxAge', 'integer', array('label' => 'open_orchestra_backoffice.form.block.max_age', 'required' => false, 'group_id' => 'technical', 'sub_group_id' => 'cache'));
     $builder->setAttribute('template', $this->generateFormManager->getTemplate($options['data']));
     $builder->addViewTransformer($this->blockToArrayTransformer);
     $builder->addEventSubscriber($this->blockFormTypeSubscriber);
     if (array_key_exists('disabled', $options)) {
         $builder->setAttribute('disabled', $options['disabled']);
     }
 }
コード例 #12
0
 /**
  * {@inheritdoc}
  *
  * @see Symfony\Component\Form.AbstractTypeExtension::buildForm()
  */
 public function buildForm(FormBuilderInterface $builder, array $options)
 {
     $dataClass = $builder->getDataClass();
     $subscriber = new AddIdentifierSubscriber($builder->getFormFactory(), $this->getJsfv());
     $builder->addEventSubscriber($subscriber);
     if (!empty($options['validation_groups'])) {
         $builder->setAttribute('validation_groups', $options['validation_groups']);
     }
     if ($dataClass !== null) {
         $builder->setAttribute('data_class', $dataClass);
     }
 }
コード例 #13
0
 /**
  * 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()
  */
 public function buildForm(FormBuilderInterface $builder, array $options)
 {
     if (!$options['loader']) {
         $loader = $this->iconFontManager->getDefaultLoader();
     } else {
         $loader = $this->iconFontManager->getLoader($options['loader']);
     }
     $loader->setData($options['loader_data']);
     $builder->setAttribute('loader', $options['loader']);
     $builder->setAttribute('loader_object', $loader);
     $builder->setAttribute('loader_data', $options['loader_data']);
 }
コード例 #14
0
 public function buildForm(FormBuilderInterface $builder, array $options)
 {
     $entities = $this->container->getParameter('shtumi.dependent_filtered_entities');
     $options['class'] = $entities[$options['entity_alias']]['class'];
     $options['property'] = $entities[$options['entity_alias']]['property'];
     $options['no_result_msg'] = $entities[$options['entity_alias']]['no_result_msg'];
     $builder->prependClientTransformer(new EntityToIdTransformer($this->container->get('doctrine')->getEntityManager(), $options['class']));
     $builder->setAttribute("parent_field", $options['parent_field']);
     $builder->setAttribute("entity_alias", $options['entity_alias']);
     $builder->setAttribute("no_result_msg", $options['no_result_msg']);
     $builder->setAttribute("empty_value", $options['empty_value']);
 }
コード例 #15
0
ファイル: AddressType.php プロジェクト: noadless/ec-cube
 /**
  * {@inheritdoc}
  */
 public function buildForm(FormBuilderInterface $builder, array $options)
 {
     $options['pref_options']['required'] = $options['required'];
     $options['addr01_options']['required'] = $options['required'];
     $options['addr02_options']['required'] = $options['required'];
     if (!isset($options['options']['error_bubbling'])) {
         $options['options']['error_bubbling'] = $options['error_bubbling'];
     }
     $builder->add($options['pref_name'], 'pref', array_merge($options['options'], $options['pref_options']))->add($options['addr01_name'], 'text', array_merge($options['options'], $options['addr01_options']))->add($options['addr02_name'], 'text', array_merge($options['options'], $options['addr02_options']))->addEventSubscriber(new \Eccube\Event\FormEventSubscriber());
     $builder->setAttribute('pref_name', $options['pref_name']);
     $builder->setAttribute('addr01_name', $options['addr01_name']);
     $builder->setAttribute('addr02_name', $options['addr02_name']);
 }
コード例 #16
0
 /**
  * {@inheritdoc}
  */
 public function buildForm(FormBuilderInterface $builder, array $options)
 {
     $entities = $this->entities;
     $options['class'] = $entities[$options['entity_alias']]['class'];
     $options['property'] = $entities[$options['entity_alias']]['property'];
     $options['no_result_msg'] = $entities[$options['entity_alias']]['no_result_msg'];
     /** @var EntityManager $manager */
     $manager = $this->doctrine->getManager();
     $builder->addViewTransformer(new EntityToIdTransformer($manager, $options['class']), true);
     $builder->setAttribute('parent_field', $options['parent_field']);
     $builder->setAttribute('entity_alias', $options['entity_alias']);
     $builder->setAttribute('no_result_msg', $options['no_result_msg']);
     $builder->setAttribute('empty_value', $options['empty_value']);
 }
 /**
  * {@inheritdoc}
  */
 public function buildForm(FormBuilderInterface $builder, array $options)
 {
     if (!$options['select2']['enabled']) {
         return;
     }
     try {
         $selector = $builder->getFormFactory()->createBuilder($options['entry_type'], null, array_merge($this->normalizeOptions($options, $options['entry_options']), array('multiple' => true)));
         $builder->setAttribute('selector', $selector);
         $builder->setAttribute('choice_loader', $selector->getOption('choice_loader'));
     } catch (UndefinedOptionsException $e) {
         $msg = 'The "%s" type is not an "choice" with Select2 extension, because: %s';
         throw new InvalidConfigurationException(sprintf($msg, $options['entry_type'], lcfirst($e->getMessage())), 0, $e);
     }
 }
コード例 #18
0
ファイル: TelType.php プロジェクト: hiroyasu55/ec-cube
 /**
  * {@inheritdoc}
  */
 public function buildForm(FormBuilderInterface $builder, array $options)
 {
     $options['tel01_options']['required'] = $options['required'];
     $options['tel02_options']['required'] = $options['required'];
     $options['tel03_options']['required'] = $options['required'];
     // required の場合は NotBlank も追加する
     if ($options['required']) {
         $options['options']['constraints'] = array_merge(array(new Assert\NotBlank(array())), $options['options']['constraints']);
     }
     if (!isset($options['options']['error_bubbling'])) {
         $options['options']['error_bubbling'] = $options['error_bubbling'];
     }
     // nameは呼び出しもので定義したものを使う
     if (empty($options['tel01_name'])) {
         $options['tel01_name'] = $builder->getName() . '01';
     }
     if (empty($options['tel02_name'])) {
         $options['tel02_name'] = $builder->getName() . '02';
     }
     if (empty($options['tel03_name'])) {
         $options['tel03_name'] = $builder->getName() . '03';
     }
     // 全角英数を事前に半角にする
     $builder->addEventSubscriber(new \Eccube\EventListener\ConvertKanaListener());
     $builder->add($options['tel01_name'], 'text', array_merge_recursive($options['options'], $options['tel01_options']))->add($options['tel02_name'], 'text', array_merge_recursive($options['options'], $options['tel02_options']))->add($options['tel03_name'], 'text', array_merge_recursive($options['options'], $options['tel03_options']));
     $builder->setAttribute('tel01_name', $options['tel01_name']);
     $builder->setAttribute('tel02_name', $options['tel02_name']);
     $builder->setAttribute('tel03_name', $options['tel03_name']);
     // todo 変
     $builder->addEventListener(FormEvents::POST_BIND, function ($event) use($builder) {
         $form = $event->getForm();
         $count = 0;
         if ($form[$builder->getName() . '01']->getData() != '') {
             $count++;
         }
         if ($form[$builder->getName() . '02']->getData() != '') {
             $count++;
         }
         if ($form[$builder->getName() . '03']->getData() != '') {
             $count++;
         }
         if ($count != 0 && $count != 3) {
             // todo メッセージをymlに入れる
             $form[$builder->getName() . '01']->addError(new FormError('全て入力してください。'));
         }
     });
     $builder->addEventSubscriber(new \Eccube\Event\FormEventSubscriber());
 }
コード例 #19
0
 /**
  * @param FormBuilderInterface $builder
  * @param array                $options
  */
 public function buildForm(FormBuilderInterface $builder, array $options)
 {
     $builder->add('file', 'file', array('label' => 'open_orchestra_media_admin.form.media.file', 'label_attr' => array('accept' => implode(',', $this->mimeTypes)), 'constraints' => array(new File(array('mimeTypes' => $this->mimeTypes)))));
     if (array_key_exists('disabled', $options)) {
         $builder->setAttribute('disabled', $options['disabled']);
     }
 }
 /**
  * @param FormBuilderInterface $builder
  * @param array                $options
  */
 public function buildForm(FormBuilderInterface $builder, array $options)
 {
     $builder->add('names', 'oo_multi_languages', array('label' => 'open_orchestra_workflow_function_admin.form.workflow_function.name', 'languages' => $this->backOfficeLanguages))->add('roles', 'oo_workflow_role_choice', array('label' => 'open_orchestra_workflow_function_admin.form.workflow_function.role', 'multiple' => true));
     if (array_key_exists('disabled', $options)) {
         $builder->setAttribute('disabled', $options['disabled']);
     }
 }
コード例 #21
0
ファイル: ReportType.php プロジェクト: vikey89/Sylius
 /**
  * {@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);
 }
 /**
  * @param FormBuilderInterface $builder
  * @param array                $options
  */
 public function buildForm(FormBuilderInterface $builder, array $options)
 {
     $builder->add('authorizations', 'collection', array('type' => 'oo_authorization', 'label' => false, 'required' => false));
     if (array_key_exists('disabled', $options)) {
         $builder->setAttribute('disabled', $options['disabled']);
     }
 }
コード例 #23
0
ファイル: EntityHiddenType.php プロジェクト: sfblaauw/pulsar
 /**
  * {@inheritdoc}
  */
 public function buildForm(FormBuilderInterface $builder, array $options)
 {
     $repository = $this->manager->getRepository($options['class']);
     $transformer = new EntityToIdentifierTransformer($repository, $options['identifier']);
     $builder->addModelTransformer($transformer);
     $builder->setAttribute('repository', $repository);
 }
コード例 #24
0
 /**
  * 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->setAttribute('csrf_factory', $builder->getFormFactory())->addEventSubscriber(new CsrfValidationListener($options['csrf_field_name'], $options['csrf_provider'], $options['intention'] ?: ($builder->getName() ?: get_class($builder->getType()->getInnerType()))));
 }
コード例 #25
0
 /**
  * @param FormBuilderInterface $builder
  * @param array                $options
  */
 public function buildForm(FormBuilderInterface $builder, array $options)
 {
     $builder->add('name', null, array('label' => 'open_orchestra_backoffice.form.status.name'))->add('published', null, array('required' => false, 'label' => 'open_orchestra_backoffice.form.status.published.label', 'attr' => array('help_text' => 'open_orchestra_backoffice.form.status.published.helper')))->add('blockedEdition', 'checkbox', array('label' => 'open_orchestra_backoffice.form.status.blocked_edition.label', 'required' => false, 'attr' => array('help_text' => 'open_orchestra_backoffice.form.status.blocked_edition.helper')))->add('outOfWorkflow', 'checkbox', array('label' => 'open_orchestra_backoffice.form.status.out_of_workflow.label', 'required' => false, 'attr' => array('help_text' => 'open_orchestra_backoffice.form.status.out_of_workflow.helper')))->add('initial', null, array('required' => false, 'label' => 'open_orchestra_backoffice.form.status.initial.label', 'attr' => array('help_text' => 'open_orchestra_backoffice.form.status.initial.helper')))->add('autoPublishFrom', null, array('required' => false, 'label' => 'open_orchestra_backoffice.form.status.auto_publish_from.label', 'attr' => array('help_text' => 'open_orchestra_backoffice.form.status.auto_publish_from.helper')))->add('autoUnpublishTo', null, array('required' => false, 'label' => 'open_orchestra_backoffice.form.status.auto_unpublish_to.label', 'attr' => array('help_text' => 'open_orchestra_backoffice.form.status.auto_unpublish_to.helper')))->add('labels', 'oo_multi_languages', array('label' => 'open_orchestra_backoffice.form.status.labels', 'languages' => $this->backOfficeLanguages))->add('displayColor', 'orchestra_color_choice', array('label' => 'open_orchestra_backoffice.form.status.display_color'));
     if (array_key_exists('disabled', $options)) {
         $builder->setAttribute('disabled', $options['disabled']);
     }
 }
コード例 #26
0
ファイル: FileType.php プロジェクト: 7rin0/BigfootCoreBundle
 /**
  * {@inheritDoc}
  */
 public function buildForm(FormBuilderInterface $builder, array $options)
 {
     if (!isset($options['filePathProperty']) || !$options['filePathProperty']) {
         throw new \Exception('BigfootFileType needs the options filePathProperty to be defined');
     }
     $builder->setAttribute('filePathProperty', $options['filePathProperty'])->setAttribute('deleteRoute', $options['deleteRoute']);
 }
コード例 #27
0
 /**
  * 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->setAttribute('csrf_factory', $builder->getFormFactory())->addEventSubscriber(new CsrfValidationListener($options['csrf_field_name'], $options['csrf_provider'], $options['intention'], $options['csrf_message'], $this->translator, $this->translationDomain));
 }
コード例 #28
0
ファイル: EntitySearchType.php プロジェクト: dstansby/camdram
 public function buildForm(FormBuilderInterface $builder, array $options)
 {
     if (!$options['text_field']) {
         $options['text_field'] = $builder->getName() . '_name';
     }
     $builder->setAttribute('text_field', $options['text_field']);
     $hidden_name = $builder->getName();
     $text_name = $options['text_field'];
     $repo = $this->em->getRepository($options['class']);
     $builder->add($text_name, 'text', array('attr' => array('class' => 'autocomplete_input'), 'mapped' => $options['other_allowed']))->add($hidden_name, 'hidden', array('data_class' => $options['class'], 'empty_data' => null))->addEventListener(FormEvents::PRE_SUBMIT, function (FormEvent $event) use($repo, $hidden_name, $text_name) {
         $data = $event->getData();
         $obj = null;
         if (is_numeric($data[$hidden_name])) {
             $obj = $repo->findOneBy(array('id' => $data[$hidden_name], 'name' => $data[$text_name]));
         }
         if (!$obj && !empty($data[$text_name])) {
             $obj = $repo->findOneByName($data[$text_name]);
         }
         if (is_null($obj)) {
             $event->setData(array($hidden_name => null, $text_name => $data[$text_name]));
         } else {
             $event->setData(array($hidden_name => $obj, $text_name => $obj->getName()));
         }
     });
 }
コード例 #29
0
 /**
  * @param FormBuilderInterface $builder
  * @param array                $options
  */
 public function buildForm(FormBuilderInterface $builder, array $options)
 {
     $builder->add('label', 'text', array('label' => 'open_orchestra_backoffice.form.keyword.label'));
     if (array_key_exists('disabled', $options)) {
         $builder->setAttribute('disabled', $options['disabled']);
     }
 }
コード例 #30
0
 /**
  * @param FormBuilderInterface $builder
  * @param array                $options
  */
 public function buildForm(FormBuilderInterface $builder, array $options)
 {
     $builder->add('name', null, array('label' => 'open_orchestra_backoffice.form.group.name'))->add('labels', 'oo_multi_languages', array('label' => 'open_orchestra_backoffice.form.group.label', 'languages' => $this->backOfficeLanguages))->add('site', 'oo_group_site_choice', array('label' => 'open_orchestra_backoffice.form.group.site', 'required' => false))->add('roles', 'oo_role_choice', array('label' => 'open_orchestra_backoffice.form.group.roles', 'multiple' => true, 'expanded' => true, 'required' => false, 'attr' => array('help_text' => 'open_orchestra_backoffice.form.group.role_helper')));
     if (array_key_exists('disabled', $options)) {
         $builder->setAttribute('disabled', $options['disabled']);
     }
 }