コード例 #1
0
 public function buildView(FormView $view, FormInterface $form, array $options)
 {
     foreach ($options as $key => $value) {
         $view->set($key, $value);
     }
     $view->set('countries', $this->_getCountryList());
 }
コード例 #2
0
 public function buildViewBottomUp(FormView $view, FormInterface $form)
 {
     foreach ($view->getChildren() as $child) {
         /* @var \Symfony\Component\Form\FormView $child */
         $child->set('full_name', $child->get('name'));
     }
 }
コード例 #3
0
ファイル: RadioType.php プロジェクト: artz20/Tv-shows-zone
 /**
  * {@inheritdoc}
  */
 public function buildView(FormView $view, FormInterface $form)
 {
     $view->set('value', $form->getAttribute('value'))->set('checked', (bool) $form->getClientData());
     if ($view->hasParent()) {
         $view->set('full_name', $view->getParent()->get('full_name'));
     }
 }
コード例 #4
0
 /**
  * {@inheritdoc}
  */
 public function buildView(FormView $view, FormInterface $form)
 {
     $configs = $form->getAttribute('configs');
     $datas = $form->getClientData();
     if (!empty($datas)) {
         if ($form->getAttribute('multiple')) {
             $datas = is_scalar($datas) ? explode(',', $datas) : $datas;
             $value = array();
             foreach ($datas as $data) {
                 if (!$data instanceof File) {
                     $data = new File($form->getAttribute('rootDir') . '/' . $data);
                 }
                 $value[] = $configs['folder'] . '/' . $data->getFilename();
             }
             $value = implode(',', $value);
         } else {
             if (!$datas instanceof File) {
                 $datas = new File($form->getAttribute('rootDir') . '/' . $datas);
             }
             $value = $configs['folder'] . '/' . $datas->getFilename();
         }
         $view->set('value', $value);
     }
     $view->set('type', 'hidden')->set('configs', $form->getAttribute('configs'));
 }
コード例 #5
0
 public function finishView(FormView $view, FormInterface $form, array $options)
 {
     $view->setAttribute('data-date', Util::ICUTojQueryDate($form->getAttribute('date_pattern')));
     $timePattern = $form->getAttribute('time_pattern');
     $view->setAttribute('data-time', Util::ICUTojQueryDate($timePattern));
     $view->setAttribute('data-ampm', false !== strpos($timePattern, 'h') ? '1' : '0');
 }
コード例 #6
0
 private function getRoot(FormView $form)
 {
     while ($form->getParent() != null) {
         $form = $form->getParent();
     }
     return $form;
 }
コード例 #7
0
ファイル: DateTimeType.php プロジェクト: nashadalam/symfony
 /**
  * {@inheritdoc}
  */
 public function buildView(FormView $view, FormInterface $form)
 {
     $view->set('widget', $form->getAttribute('widget'));
     if ('single_text' === $form->getAttribute('widget')) {
         $view->set('type', 'datetime');
     }
 }
コード例 #8
0
 public function buildView(FormView $view, FormInterface $form, array $options)
 {
     $view->set('parent_field', $form->getAttribute('parent_field'));
     $view->set('entity_alias', $form->getAttribute('entity_alias'));
     $view->set('no_result_msg', $form->getAttribute('no_result_msg'));
     $view->set('empty_value', $form->getAttribute('empty_value'));
 }
コード例 #9
0
ファイル: ZCodeExtension.php プロジェクト: Nek-/ZCodeBundle
 public function zform(\Symfony\Component\Form\FormView $field)
 {
     $attr = $field->get('attr', array());
     $attr['class'] = 'zTextForm';
     $field->set('attr', $attr);
     return $this->helper->render(array('field' => $field, 'id' => 1));
 }
コード例 #10
0
 /**
  * {@inheritdoc}
  */
 public function buildView(FormView $view, FormInterface $form)
 {
     $value = $form->getClientData();
     // set string representation
     if (true === $value) {
         $value = 'true';
     } else {
         if (false === $value) {
             $value = 'false';
         } else {
             if (null === $value) {
                 $value = 'null';
             } else {
                 if (is_array($value)) {
                     $value = implode(', ', $value);
                 } else {
                     if ($value instanceof \DateTime) {
                         $value = $value->format('Y-m-d H:i:s');
                     } else {
                         if (is_object($value)) {
                             if (method_exists($value, '__toString')) {
                                 $value = $value->__toString();
                             } else {
                                 $value = get_class($value);
                             }
                         }
                     }
                 }
             }
         }
     }
     $view->set('value', (string) $value);
 }
コード例 #11
0
 /**
  * @param \Symfony\Component\Form\FormView      $view
  * @param \Symfony\Component\Form\FormInterface $form
  */
 public function buildView(FormView $view, FormInterface $form)
 {
     $format = $form->getAttribute('format');
     $imageSrc = $view->get('image_src');
     if ($imageSrc !== null && $format !== null) {
         $view->set('image_src', $this->imManager->getUrl($format, $imageSrc));
     }
 }
コード例 #12
0
 function it_changes_label_attribute_for(FormInterface $form, FormView $view, FormView $fileView)
 {
     $form->getName()->willReturn('file');
     $view->offsetGet('file')->willReturn($fileView);
     $view->vars = array('label_attr' => array());
     $fileView->vars = array('id' => 'form_file_file');
     $this->finishView($view, $form, array());
     expect($view->vars['label_attr']['for'])->toBe('form_file_file');
 }
コード例 #13
0
 /**
  * Removes CSRF fields from all the form views except the root one.
  *
  * @param FormView      $view The form view
  * @param FormInterface $form The form
  */
 public function buildViewBottomUp(FormView $view, FormInterface $form)
 {
     if ($view->hasParent() && $form->hasAttribute('csrf_field_name')) {
         $name = $form->getAttribute('csrf_field_name');
         if (isset($view[$name])) {
             unset($view[$name]);
         }
     }
 }
コード例 #14
0
ファイル: NodeType.php プロジェクト: xavier-dubreuil/LightCMS
 public function finishView(FormView $view, FormInterface $form, array $options)
 {
     /** @var FormView[] $fields */
     if ($view->offsetExists('submit_group')) {
         $fields = array($view->offsetGet('submit_group'));
         $view->offsetUnset('submit_group');
         $view->children = $view->children + $fields;
     }
     parent::finishView($view, $form, $options);
 }
コード例 #15
0
ファイル: FileUploadType.php プロジェクト: firano/form-bundle
 public function finishView(FormView $view, FormInterface $form, array $options)
 {
     $configs = array_merge($options['configs'], array('id' => $view->vars['id'], 'name_id' => $view->getChild('name')->vars['id'], 'original_name_id' => $view->getChild('originalName')->vars['id'], 'size_id' => $view->getChild('size')->vars['id'], 'title_id' => $view->getChild('title')->vars['id'], 'caption_id' => $view->getChild('caption')->vars['id'], 'description_id' => $view->getChild('description')->vars['id'], 'hash_id' => $view->getChild('hash')->vars['id'], 'enabled_id' => $view->getChild('enabled')->vars['id'], 'scheduled_for_deletion_id' => $view->getChild('scheduledForDeletion')->vars['id'], 'enabled_value' => false));
     $file = $form->getData();
     if ($file instanceof FileInterface && null !== $file->getId()) {
         $configs['enabled_value'] = $file->isEnabled();
     }
     $this->session->set($view->vars['id'], $configs);
     $view->vars['configs'] = $configs;
 }
コード例 #16
0
    /**
     * {@inheritdoc}
     */
    public function buildView(FormView $view, FormInterface $form)
    {
        $view
            ->set('allow_add', $form->getAttribute('allow_add'))
            ->set('allow_delete', $form->getAttribute('allow_delete'))
        ;

        if ($form->hasAttribute('prototype')) {
            $view->set('prototype', $form->getAttribute('prototype'));
        }
    }
コード例 #17
0
ファイル: FormType.php プロジェクト: rfc1483/doctrine
 public function buildViewBottomUp(FormView $view, FormInterface $form)
 {
     $multipart = false;
     foreach ($view->getChildren() as $child) {
         if ($child->get('multipart')) {
             $multipart = true;
             break;
         }
     }
     $view->set('multipart', $multipart);
 }
コード例 #18
0
 /**
  * {@inheritdoc}
  */
 public function buildView(FormView $view, FormInterface $form)
 {
     $configs = $form->getAttribute('configs');
     $year = $form->getAttribute('years');
     $configs['dateFormat'] = 'yy-mm-dd';
     if ('single_text' === $form->getAttribute('widget')) {
         $formatter = $form->getAttribute('formatter');
         $configs['dateFormat'] = $this->getJavascriptPattern($formatter);
     }
     $view->set('min_year', min($year))->set('max_year', max($year))->set('configs', $configs)->set('culture', $form->getAttribute('culture'));
 }
コード例 #19
0
 /**
  * Adds a CSRF field to the root form view.
  *
  * @param FormView      $view The form view
  * @param FormInterface $form The form
  */
 public function buildViewBottomUp(FormView $view, FormInterface $form)
 {
     if (!$view->hasParent() && !$form->getAttribute('single_control') && $form->hasAttribute('csrf_field_name')) {
         $name = $form->getAttribute('csrf_field_name');
         $csrfProvider = $form->getAttribute('csrf_provider');
         $intention = $form->getAttribute('csrf_intention');
         $factory = $form->getAttribute('csrf_factory');
         $data = $csrfProvider->generateCsrfToken($intention);
         $csrfForm = $factory->createNamed('hidden', $name, $data, array('property_path' => false));
         $view->addChild($csrfForm->createView($view));
     }
 }
コード例 #20
0
ファイル: ChoiceType.php プロジェクト: artz20/Tv-shows-zone
 /**
  * {@inheritdoc}
  */
 public function buildView(FormView $view, FormInterface $form)
 {
     $choices = $form->getAttribute('choice_list')->getChoices();
     $preferred = array_flip($form->getAttribute('preferred_choices'));
     $view->set('multiple', $form->getAttribute('multiple'))->set('expanded', $form->getAttribute('expanded'))->set('preferred_choices', array_intersect_key($choices, $preferred))->set('choices', array_diff_key($choices, $preferred))->set('separator', '-------------------')->set('empty_value', $form->getAttribute('empty_value'));
     if ($view->get('multiple') && !$view->get('expanded')) {
         // Add "[]" to the name in case a select tag with multiple options is
         // displayed. Otherwise only one of the selected options is sent in the
         // POST request.
         $view->set('full_name', $view->get('full_name') . '[]');
     }
 }
コード例 #21
0
 public function testgetChildFormView()
 {
     $container = $this->getMock('Symfony\\Component\\DependencyInjection\\ContainerInterface');
     $pool = new Pool($container, 'title', 'logo.png');
     $helper = new AdminHelper($pool);
     $formView = new FormView();
     $formView->set('id', 'test');
     $child = new FormView();
     $child->set('id', 'test_elementId');
     $formView->setChildren(array('elementId' => $child));
     $this->assertNull($helper->getChildFormView($formView, 'foo'));
     $this->isInstanceOf('Symfony\\Component\\Form\\FormView', $helper->getChildFormView($formView, 'test_elementId'));
 }
コード例 #22
0
ファイル: ImageType.php プロジェクト: r4cker/lowbi
 /**
  * {@inheritdoc}
  */
 public function buildView(FormView $view, FormInterface $form)
 {
     $request = $this->request;
     $configs = $form->getAttribute('configs');
     $data = $form->getClientData();
     $fileMeta = new Upload();
     $uploadDir = "/web/temp";
     $uploadDir .= '/' . date("Y") . '/' . date("m") . '/' . date("d");
     $relativeFilePath = $uploadDir;
     $absolutePath = str_replace('/', '//', $request->getRootDir());
     $absolutePath = str_replace('\\', '\\\\', $absolutePath);
     if (!empty($data)) {
         $absoluteFilePath = $request->getRootDir() . '/../' . $data->getPath() . '/' . $data->getUniqId();
         $relativeFilePath = $data->getPath() . '/' . $data->getUniqId();
         $relativePath = $data->getPath();
         $fileMeta = $this->em->getRepository('LowbiSystemBundle:Upload')->find($data->getId());
         if ($fileMeta == null) {
             $fileMeta = new Upload();
         }
         if ($fileMeta->getTodelete()) {
             try {
                 $this->em->remove($fileMeta);
                 $this->em->flush();
             } catch (\EXception $ex) {
             }
             $view->set('filePath', $relativeFilePath)->set('absolutePath', $absolutePath)->set('value', null)->set('fileMeta', $fileMeta);
             return;
         }
         if (!$data instanceof Image) {
             if ($data instanceof File) {
                 $data = new \Lowbi\SystemBundle\Gd\File\Image($absoluteFilePath);
             } else {
                 $data = new \Lowbi\SystemBundle\Gd\File\Image($absoluteFilePath);
             }
         }
         //if ($data->hasThumbnail($this->selected)) {
         $thumbnail = $data->getThumbnail($this->selected);
         $view->set('thumbnail', array('file' => $relativePath . '/' . $thumbnail->getFilename(), 'width' => $thumbnail->getWidth(), 'height' => $thumbnail->getHeight()));
         //}
         if ($configs['custom_storage_folder'] && false === ($value = $form->getClientData()) instanceof File) {
             // This if will be executed only when we load entity with existing file pointed to the folder different
             // from $configs['folder']
         } else {
             $value = $configs['folder'] . '/' . $data->getFilename();
         }
         $view->set('value', $value)->set('file', $value)->set('width', $data->getWidth())->set('height', $data->getHeight())->set('filePath', $relativeFilePath)->set('absolutePath', $absolutePath)->set('fileMeta', $fileMeta);
     } else {
         $view->set('filePath', $relativeFilePath)->set('absolutePath', $absolutePath)->set('fileMeta', $fileMeta);
     }
     $view->set('filters', $this->filters);
 }
コード例 #23
0
 /**
  * {@inheritdoc}
  */
 public function buildView(FormView $view, FormInterface $form)
 {
     if (!$this->enabled) {
         return;
     }
     if ($this->secure) {
         $server = self::RECAPTCHA_API_SECURE_SERVER;
     } else {
         $server = self::RECAPTCHA_API_SERVER;
     }
     $view->set('url_challenge', $server . '/challenge?k=' . $this->publicKey);
     $view->set('url_noscript', $server . '/noscript?k=' . $this->publicKey);
     $view->set('public_key', $this->publicKey);
     $view->set('ewz_recaptcha_enabled', $this->enabled);
 }
コード例 #24
0
 /**
  * {@inheritdoc}
  */
 public function buildView(FormView $view, FormInterface $form)
 {
     $datas = json_decode($form->getClientData(), true);
     $value = '';
     if (!empty($datas)) {
         if ($form->getAttribute('multiple')) {
             foreach ($datas as $data) {
                 $value .= $data['label'] . ', ';
             }
         } else {
             $value = $datas['label'];
         }
     }
     $view->set('autocompleter_value', $value)->set('route_name', $form->getAttribute('route_name'))->set('freeValues', $form->getAttribute('freeValues'));
 }
コード例 #25
0
 /**
  * {@inheritdoc}
  */
 public function buildView(FormView $view, FormInterface $form)
 {
     $values = $view->get('value');
     $selecteds = array_flip($values);
     $choices_selected = $choices_unselected = array();
     //Rebuilds choices
     foreach ($this->choices as $key => $choice) {
         if (isset($selecteds[$key])) {
             $choices_selected[$key] = $choice;
         } else {
             $choices_unselected[$key] = $choice;
         }
     }
     $view->set('choices_selected', $choices_selected);
     $view->set('choices_unselected', $choices_unselected);
 }
コード例 #26
0
ファイル: RatingType.php プロジェクト: r4cker/lowbi
 /**
  * {@inheritdoc}
  */
 public function buildView(FormView $view, FormInterface $form)
 {
     $scale = $form->getAttribute('scale');
     $oneVote = $form->getAttribute('oneVote');
     if ($oneVote == null) {
         $oneVote = false;
     }
     if ($scale == null) {
         $scale = 5;
     }
     $choices = array();
     for ($i = 0; $i <= $scale; $i++) {
         $choices[$i] = $i;
     }
     $view->set('configs', $form->getAttribute('configs'))->set('scale', $form->getAttribute('scale'))->set('choices', $choices)->set('oneVote', $oneVote)->set('read_only', $form->getParent()->isReadOnly());
 }
コード例 #27
0
ファイル: DateType.php プロジェクト: rcambien/symfony
 /**
  * {@inheritdoc}
  */
 public function buildViewBottomUp(FormView $view, FormInterface $form)
 {
     $view->set('widget', $form->getAttribute('widget'));
     if ($view->hasChildren()) {
         $pattern = $form->getAttribute('formatter')->getPattern();
         // set right order with respect to locale (e.g.: de_DE=dd.MM.yy; en_US=M/d/yy)
         // lookup various formats at http://userguide.icu-project.org/formatparse/datetime
         if (preg_match('/^([yMd]+).+([yMd]+).+([yMd]+)$/', $pattern)) {
             $pattern = preg_replace(array('/y+/', '/M+/', '/d+/'), array('{{ year }}', '{{ month }}', '{{ day }}'), $pattern);
         } else {
             // default fallback
             $pattern = '{{ year }}-{{ month }}-{{ day }}';
         }
         $view->set('date_pattern', $pattern);
     }
 }
コード例 #28
0
 /**
  * {@inheritdoc}
  */
 public function buildView(FormView $view, FormInterface $form, array $options)
 {
     $configs = $options['configs'];
     $data = $form->getClientData();
     if (!empty($data)) {
         if (!$data instanceof Image) {
             $data = new Image($form->getAttribute('rootDir') . '/' . $data);
         }
         if ($data->hasThumbnail($this->selected)) {
             $thumbnail = $data->getThumbnail($this->selected);
             $view->setVar('thumbnail', array('file' => $configs['folder'] . '/' . $thumbnail->getFilename(), 'width' => $thumbnail->getWidth(), 'height' => $thumbnail->getHeight()));
         }
         $value = $configs['folder'] . '/' . $data->getFilename();
         $view->vars = array_replace($view->vars, array('value' => $value, 'file' => $value, 'width' => $data->getWidth(), 'height' => $data->getHeight()));
     }
     $view->vars['filters'] = $this->filters;
 }
コード例 #29
0
 /**
  * {@inheritdoc}
  */
 public function buildView(FormView $view, FormInterface $form)
 {
     $configs = $form->getAttribute('configs');
     $data = $form->getClientData();
     if (!empty($data)) {
         if (!$data instanceof Image) {
             $data = new Image($form->getAttribute('rootDir') . '/' . $data);
         }
         if ($data->hasThumbnail($this->selected)) {
             $thumbnail = $data->getTumbnail($this->selected);
             $view->set('thumbnail', array('file' => $configs['folder'] . '/' . $thumbnail->getFilename(), 'width' => $thumbnail->getWidth(), 'height' => $thumbnail->getHeight()));
         }
         $value = $configs['folder'] . '/' . $data->getFilename();
         $view->set('value', $value)->set('file', $value)->set('width', $data->getWidth())->set('height', $data->getHeight());
     }
     $view->set('filters', $this->filters);
 }
コード例 #30
0
ファイル: TreeType.php プロジェクト: r4cker/lowbi
 public function buildView(FormView $view, FormInterface $form)
 {
     $repo = $this->em->getRepository($form->getAttribute('class'));
     $nodeEmpty[] = array('id' => null, 'title' => 'Aucun', 'icon' => null, '__children' => null);
     $treeNodes = $repo->childrenHierarchy(null, false, array('decorate' => false));
     $treeArray = array_merge($nodeEmpty, $treeNodes);
     $treeHtml = $this->createHtmlTree($treeArray, 0);
     $vars = $view->getVars();
     $value = $vars['value'];
     if ($value != null) {
         $selectedNode = $repo->find($value);
         $treepath = $this->getTreePath($selectedNode);
     } else {
         $treepath = '/';
     }
     $view->set('configs', $form->getAttribute('configs'))->set('class', $form->getAttribute('class'))->set('property', $form->getAttribute('property'))->set('treeHtml', $treeHtml)->set('treePath', $treepath);
 }