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


PHP FormInterface::hasAttribute方法代码示例

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


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

示例1: buildViewBottomUp

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

示例2: 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

示例3: buildViewBottomUp

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

示例4: buildView

 /**
  * {@inheritdoc}
  */
 public function buildView(FormViewInterface $view, FormInterface $form, array $options)
 {
     $datas = json_decode($form->getClientData(), true);
     $value = '';
     if (false === empty($datas)) {
         if (true === $form->getAttribute('multiple')) {
             foreach ($datas as $data) {
                 $value .= $data['label'] . ', ';
             }
         } else {
             $value = $datas['label'];
         }
     }
     $view->set('tokeninput_value', $value)->set('route_name', $form->getAttribute('route_name'));
     foreach ($this->_availableTokeninputOptions as $option) {
         if ($form->hasAttribute($option)) {
             $view->set($option, $form->getAttribute($option));
         }
     }
 }
开发者ID:r4cker,项目名称:GenemuFormBundle,代码行数:23,代码来源:TokeninputType.php

示例5: getFormValidationGroups

 protected static function getFormValidationGroups(FormInterface $form)
 {
     $groups = null;
     if ($form->hasAttribute('validation_groups')) {
         $groups = $form->getAttribute('validation_groups');
         if (is_callable($groups)) {
             $groups = (array) call_user_func($groups, $form);
         }
     }
     $currentForm = $form;
     while (!$groups && $currentForm->hasParent()) {
         $currentForm = $currentForm->getParent();
         if ($currentForm->hasAttribute('validation_groups')) {
             $groups = $currentForm->getAttribute('validation_groups');
             if (is_callable($groups)) {
                 $groups = (array) call_user_func($groups, $currentForm);
             }
         }
     }
     if (null === $groups) {
         $groups = array('Default');
     }
     return (array) $groups;
 }
开发者ID:rouffj,项目名称:symfony,代码行数:24,代码来源:DelegatingValidationListener.php

示例6: buildViewBottomUp

 /**
  * {@inheritdoc}
  */
 public function buildViewBottomUp(FormView $view, FormInterface $form)
 {
     if ($form->hasAttribute('prototype') && $view->get('prototype')->get('multipart')) {
         $view->set('multipart', true);
     }
 }
开发者ID:realestateconz,项目名称:symfony,代码行数:9,代码来源:CollectionType.php


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