当前位置: 首页>>代码示例>>PHP>>正文


PHP FormView::set方法代码示例

本文整理汇总了PHP中Symfony\Component\Form\FormView::set方法的典型用法代码示例。如果您正苦于以下问题:PHP FormView::set方法的具体用法?PHP FormView::set怎么用?PHP FormView::set使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Symfony\Component\Form\FormView的用法示例。


在下文中一共展示了FormView::set方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: buildView

 /**
  * {@inheritdoc}
  */
 public function buildView(FormView $view, FormInterface $form)
 {
     $view->set('widget', $form->getAttribute('widget'));
     if ('single_text' === $form->getAttribute('widget')) {
         $view->set('type', 'datetime');
     }
 }
开发者ID:nashadalam,项目名称:symfony,代码行数:10,代码来源:DateTimeType.php

示例2: buildView

 /**
  * @param \Symfony\Component\Form\FormView $view
  * @param \Symfony\Component\Form\FormInterface $form
  */
 public function buildView(FormView $view, FormInterface $form)
 {
     $sonataAdmin = $form->getAttribute('sonata_admin');
     // avoid to add extra information not required by non admin field
     if ($form->getAttribute('sonata_admin_enabled', true)) {
         $sonataAdmin['value'] = $form->getData();
         // add a new block types, so the Admin Form element can be tweaked based on the admin code
         $types = $view->get('types');
         $baseName = str_replace('.', '_', $sonataAdmin['field_description']->getAdmin()->getCode());
         $baseType = $types[count($types) - 1];
         $types[] = sprintf('%s_%s', $baseName, $baseType);
         $types[] = sprintf('%s_%s_%s', $baseName, $sonataAdmin['field_description']->getName(), $baseType);
         if ($sonataAdmin['block_name']) {
             $types[] = $sonataAdmin['block_name'];
         }
         $view->set('types', $types);
         $view->set('sonata_admin_enabled', true);
         $view->set('sonata_admin', $sonataAdmin);
         $attr = $view->get('attr', array());
         if (!isset($attr['class'])) {
             $attr['class'] = $sonataAdmin['class'];
         }
         $view->set('attr', $attr);
     } else {
         $view->set('sonata_admin_enabled', false);
     }
     $view->set('sonata_admin', $sonataAdmin);
 }
开发者ID:nzzdev,项目名称:SonataAdminBundle,代码行数:32,代码来源:FormTypeFieldExtension.php

示例3: buildView

 public function buildView(FormView $view, FormInterface $form, array $options)
 {
     foreach ($options as $key => $value) {
         $view->set($key, $value);
     }
     $view->set('countries', $this->_getCountryList());
 }
开发者ID:TMBaay,项目名称:MEDTrip---Healthcareabroad,代码行数:7,代码来源:FancyCountryFieldType.php

示例4: buildView

 /**
  * {@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'));
 }
开发者ID:raziel057,项目名称:GenemuFormBundle,代码行数:28,代码来源:FileType.php

示例5: buildView

 /**
  * {@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'));
     }
 }
开发者ID:artz20,项目名称:Tv-shows-zone,代码行数:10,代码来源:RadioType.php

示例6: buildView

 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'));
 }
开发者ID:nucleartux,项目名称:ShtumiUsefulBundle1,代码行数:7,代码来源:DependentFilteredEntityType.php

示例7: buildView

    /**
     * {@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'));
        }
    }
开发者ID:pmjones,项目名称:php-framework-benchmarks,代码行数:14,代码来源:CollectionType.php

示例8: buildView

 /**
  * {@inheritdoc}
  */
 public function buildView(FormView $view, FormInterface $form, array $options)
 {
     $choiceList = $form->getAttribute('choice_list');
     // We should not load anything right now when loading via ajax
     $view->set('multiple', $form->getAttribute('multiple'))->set('expanded', $form->getAttribute('expanded'))->set('preferred_choices', array())->set('choices', array())->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') . '[]');
     }
 }
开发者ID:rodrigopluz,项目名称:BFOSBrasilBundle,代码行数:15,代码来源:AjaxChoiceType.php

示例9: buildView

 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', '');
     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') . '[]');
     }
 }
开发者ID:rfc1483,项目名称:blog,代码行数:12,代码来源:ChoiceType.php

示例10: buildView

 /**
  * {@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);
 }
开发者ID:ruian,项目名称:EWZRecaptchaBundle,代码行数:18,代码来源:RecaptchaType.php

示例11: buildView

 /**
  * {@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);
 }
开发者ID:raziel057,项目名称:GenemuFormBundle,代码行数:36,代码来源:PlainType.php

示例12: buildView

 /**
  * {@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);
 }
开发者ID:norfil,项目名称:AdmingeneratorGeneratorBundle,代码行数:19,代码来源:PropelDoubleListType.php

示例13: buildView

 /**
  * {@inheritdoc}
  */
 public function buildView(FormView $view, FormInterface $form)
 {
     $name = $form->getName();
     $readOnly = $form->getAttribute('read_only');
     if ($view->hasParent()) {
         if ('' === $name) {
             throw new FormException('Form node with empty name can be used only as root form node.');
         }
         if ('' !== ($parentFullName = $view->getParent()->get('full_name'))) {
             $id = sprintf('%s_%s', $view->getParent()->get('id'), $name);
             $fullName = sprintf('%s[%s]', $parentFullName, $name);
         } else {
             $id = $name;
             $fullName = $name;
         }
         // Complex fields are read-only if themselves or their parent is.
         $readOnly = $readOnly || $view->getParent()->get('read_only');
     } else {
         $id = $name;
         $fullName = $name;
         // Strip leading underscores and digits. These are allowed in
         // form names, but not in HTML4 ID attributes.
         // http://www.w3.org/TR/html401/struct/global.html#adef-id
         $id = ltrim($id, '_0123456789');
     }
     $types = array();
     foreach ($form->getTypes() as $type) {
         $types[] = $type->getName();
     }
     $view->set('form', $view)->set('id', $id)->set('name', $name)->set('full_name', $fullName)->set('read_only', $readOnly)->set('errors', $form->getErrors())->set('value', $form->getClientData())->set('disabled', $form->isDisabled())->set('required', $form->isRequired())->set('max_length', $form->getAttribute('max_length'))->set('pattern', $form->getAttribute('pattern'))->set('size', null)->set('label', $form->getAttribute('label'))->set('multipart', false)->set('attr', $form->getAttribute('attr'))->set('types', $types)->set('translation_domain', $form->getAttribute('translation_domain'));
 }
开发者ID:nicodmf,项目名称:symfony,代码行数:34,代码来源:FieldType.php

示例14: zform

 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));
 }
开发者ID:Nek-,项目名称:ZCodeBundle,代码行数:7,代码来源:ZCodeExtension.php

示例15: buildView

 /**
  * {@inheritdoc}
  */
 public function buildView(FormView $view, FormInterface $form)
 {
     $name = $form->getName();
     if ($view->hasParent()) {
         if ('' === $name) {
             throw new FormException('Form node with empty name can be used only as root form node.');
         }
         if ('' !== ($parentFullName = $view->getParent()->get('full_name'))) {
             $id = sprintf('%s_%s', $view->getParent()->get('id'), $name);
             $fullName = sprintf('%s[%s]', $parentFullName, $name);
         } else {
             $id = $name;
             $fullName = $name;
         }
     } else {
         // If this form node have empty name, set id to `form`
         // to avoid rendering `id=""` in html structure
         $id = $name ?: 'form';
         $fullName = $name;
     }
     $types = array();
     foreach ($form->getTypes() as $type) {
         $types[] = $type->getName();
     }
     $view->set('form', $view)->set('id', $id)->set('name', $name)->set('full_name', $fullName)->set('errors', $form->getErrors())->set('value', $form->getClientData())->set('read_only', $form->isReadOnly())->set('required', $form->isRequired())->set('max_length', $form->getAttribute('max_length'))->set('pattern', $form->getAttribute('pattern'))->set('size', null)->set('label', $form->getAttribute('label'))->set('multipart', false)->set('attr', $form->getAttribute('attr'))->set('types', $types)->set('translation_domain', $form->getAttribute('translation_domain'));
 }
开发者ID:rudott,项目名称:symfony,代码行数:29,代码来源:FieldType.php


注:本文中的Symfony\Component\Form\FormView::set方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。