php Symfony-Component-Form-FormView类(方法)实例源码

下面列出了php Symfony-Component-Form-FormView 类(方法)源码代码实例,从而了解它的用法。

作者:TMBaa    项目:MEDTrip---Healthcareabroa   
public function buildView(FormView $view, FormInterface $form, array $options)
 {
     foreach ($options as $key => $value) {
         $view->set($key, $value);
     }
     $view->set('countries', $this->_getCountryList());
 }

作者:hatimeri    项目:HatimeriaDotpayBundl   
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'));
     }
 }

作者:artz2    项目:Tv-shows-zon   
/**
  * {@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'));
     }
 }

作者:raziel05    项目:GenemuFormBundl   
/**
  * {@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'));
 }

作者:senthilkumar328    项目:LyraAdminBundl   
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');
 }

作者:rtznprmpft    项目:Zikulacor   
private function getRoot(FormView $form)
 {
     while ($form->getParent() != null) {
         $form = $form->getParent();
     }
     return $form;
 }

作者:nashadala    项目:symfon   
/**
  * {@inheritdoc}
  */
 public function buildView(FormView $view, FormInterface $form)
 {
     $view->set('widget', $form->getAttribute('widget'));
     if ('single_text' === $form->getAttribute('widget')) {
         $view->set('type', 'datetime');
     }
 }

作者:nucleartu    项目:ShtumiUsefulBundle   
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'));
 }

作者:Nek    项目:ZCodeBundl   
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));
 }

作者:raziel05    项目:GenemuFormBundl   
/**
  * {@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);
 }

作者:nacmarti    项目:SnowcapImBundl   
/**
  * @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));
     }
 }

作者:norzechowic    项目:doctrine-extensions-bundl   
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');
 }

作者:artz2    项目:Tv-shows-zon   
/**
  * 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]);
         }
     }
 }

作者:xavier-dubreui    项目:LightCM   
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);
 }

作者:firan    项目:form-bundl   
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;
 }

作者:pmjone    项目:php-framework-benchmark   
/**
     * {@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'));
        }
    }

作者:rfc148    项目:doctrin   
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);
 }

作者:raziel05    项目:GenemuFormBundl   
/**
  * {@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'));
 }

作者:rikai    项目:symfon   
/**
  * 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));
     }
 }

作者:artz2    项目:Tv-shows-zon   
/**
  * {@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') . '[]');
     }
 }


问题


面经


文章

微信
公众号

扫码关注公众号