當前位置: 首頁>>代碼示例>>PHP>>正文


PHP FormView::getParent方法代碼示例

本文整理匯總了PHP中Symfony\Component\Form\FormView::getParent方法的典型用法代碼示例。如果您正苦於以下問題:PHP FormView::getParent方法的具體用法?PHP FormView::getParent怎麽用?PHP FormView::getParent使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Symfony\Component\Form\FormView的用法示例。


在下文中一共展示了FormView::getParent方法的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: 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:421p,項目名稱:symfony,代碼行數:34,代碼來源:FormType.php

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

示例3: buildView

 public function buildView(FormView $view, FormInterface $form)
 {
     if ($view->hasParent()) {
         $parentId = $view->getParent()->get('id');
         $parentName = $view->getParent()->get('name');
         $id = sprintf('%s_%s', $parentId, $form->getName());
         $name = sprintf('%s[%s]', $parentName, $form->getName());
     } else {
         $id = $form->getName();
         $name = $form->getName();
     }
     $view->set('form', $view);
     $view->set('id', $id);
     $view->set('name', $name);
     $view->set('errors', $form->getErrors());
     $view->set('value', $form->getClientData());
     $view->set('read_only', $form->isReadOnly());
     $view->set('required', $form->isRequired());
     $view->set('max_length', $form->getAttribute('max_length'));
     $view->set('size', null);
     $view->set('label', $form->getAttribute('label'));
     $view->set('multipart', false);
     $view->set('attr', array());
     $types = array();
     foreach (array_reverse((array) $form->getTypes()) as $type) {
         $types[] = $type->getName();
     }
     $view->set('types', $types);
 }
開發者ID:norwayapp,項目名稱:Invest,代碼行數:29,代碼來源:FieldType.php

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

示例5: getRoot

 private function getRoot(FormView $form)
 {
     while ($form->getParent() != null) {
         $form = $form->getParent();
     }
     return $form;
 }
開發者ID:rtznprmpftl,項目名稱:Zikulacore,代碼行數:7,代碼來源:FieldErrors.php

示例6: lookupTemplate

 /**
  * Returns the name of the template to use to render the block
  *
  * @param FormView $view  The form view
  * @param string   $block The name of the block
  *
  * @return string|Boolean The template logical name or false when no template is found
  */
 protected function lookupTemplate(FormView $view, $block)
 {
     $file = $block . '.html.php';
     $id = $view->get('id');
     if (!isset($this->templates[$id][$block])) {
         $template = false;
         $themes = $view->hasParent() ? array() : $this->resources;
         if (isset($this->themes[$id])) {
             $themes = array_merge($themes, $this->themes[$id]);
         }
         for ($i = count($themes) - 1; $i >= 0; --$i) {
             if ($this->engine->exists($templateName = $themes[$i] . ':' . $file)) {
                 $template = $templateName;
                 break;
             }
         }
         if (false === $template && $view->hasParent()) {
             $template = $this->lookupTemplate($view->getParent(), $block);
         }
         $this->templates[$id][$block] = $template;
     }
     return $this->templates[$id][$block];
 }
開發者ID:robertowest,項目名稱:CuteFlow-V4,代碼行數:31,代碼來源:FormHelper.php

示例7: getPassword

 /**
  * Get password.
  * TODO: 無理矢理パスワードを取得してる為、もうちょい考えてみる
  */
 public function getPassword(FormView $view)
 {
     $method = 'get' . ucfirst($view->get('name'));
     return $view->getParent()->get('value')->{$method}();
 }
開發者ID:ryster,項目名稱:HaouFormBundle,代碼行數:9,代碼來源:FormExtension.php

示例8: buildView

 /**
  * {@inheritdoc}
  */
 public function buildView(FormView $view, FormInterface $form)
 {
     if ($view->hasParent()) {
         $view->set('full_name', $view->getParent()->get('full_name'));
     }
 }
開發者ID:nicodmf,項目名稱:symfony,代碼行數:9,代碼來源:RadioType.php


注:本文中的Symfony\Component\Form\FormView::getParent方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。