當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。