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


PHP FormView::all方法代碼示例

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


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

示例1: renderSection

 /**
  * Renders a template.
  *
  * 1. This function first looks for a block named "_<view id>_<section>",
  * 2. if such a block is not found the function will look for a block named
  *    "<type name>_<section>",
  * 3. the type name is recursively replaced by the parent type name until a
  *    corresponding block is found
  *
  * @param FormView  $view       The form view
  * @param string    $section    The section to render (i.e. 'row', 'widget', 'label', ...)
  * @param array     $variables  Additional variables
  *
  * @return string The html markup
  *
  * @throws FormException if no template block exists to render the given section of the view
  */
 protected function renderSection(FormView $view, $section, array $variables = array())
 {
     $mainTemplate = in_array($section, array('row', 'widget'));
     if ($mainTemplate && $view->isRendered()) {
         return '';
     }
     $template = null;
     $custom = '_' . $view->get('id');
     $rendering = $custom . $section;
     if (isset($this->varStack[$rendering])) {
         $typeIndex = $this->varStack[$rendering]['typeIndex'] - 1;
         $types = $this->varStack[$rendering]['types'];
         $variables = array_replace_recursive($this->varStack[$rendering]['variables'], $variables);
     } else {
         $types = $view->get('types');
         $types[] = $custom;
         $typeIndex = count($types) - 1;
         $variables = array_replace_recursive($view->all(), $variables);
         $this->varStack[$rendering]['types'] = $types;
     }
     $this->varStack[$rendering]['variables'] = $variables;
     do {
         $types[$typeIndex] .= '_' . $section;
         $template = $this->lookupTemplate($view, $types[$typeIndex]);
         if ($template) {
             $this->varStack[$rendering]['typeIndex'] = $typeIndex;
             $this->context[] = array('variables' => $variables, 'view' => $view);
             $html = $this->engine->render($template, $variables);
             array_pop($this->context);
             unset($this->varStack[$rendering]);
             if ($mainTemplate) {
                 $view->setRendered();
             }
             return $html;
         }
     } while (--$typeIndex >= 0);
     throw new FormException(sprintf('Unable to render the form as none of the following blocks exist: "%s".', implode('", "', array_reverse($types))));
 }
開發者ID:robertowest,項目名稱:CuteFlow-V4,代碼行數:55,代碼來源:FormHelper.php

示例2: renderSection

    protected function renderSection(FormView $view, $section, array $variables = array())
    {
        $template = null;
        $blocks = $view->get('types');

        foreach ($blocks as &$block) {
            $block = $block.'_'.$section;
            $template = $this->lookupTemplate($block);

            if ($template) {
                break;
            }
        }

        if (!$template) {
            throw new FormException(sprintf('Unable to render form as none of the following blocks exist: "%s".', implode('", "', $blocks)));
        }

        if ('widget' === $section || 'row' === $section) {
            $view->setRendered();
        }

        return $this->render($template, array_merge($view->all(), $variables));
    }
開發者ID:nacef,項目名稱:symfony,代碼行數:24,代碼來源:FormHelper.php

示例3: render

    public function render(FormView $view, $template, array $variables = array())
    {
        $this->varStack[$view] = array_replace(
            $view->all(),
            isset($this->varStack[$view]) ? $this->varStack[$view] : array(),
            $variables
        );

        $this->viewStack[] = $view;

        $html = $this->engine->render($template, $this->varStack[$view]);

        array_pop($this->viewStack);
        unset($this->varStack[$view]);

        return $html;
    }
開發者ID:n3b,項目名稱:symfony,代碼行數:17,代碼來源:FormHelper.php

示例4: render

 protected function render(FormView $view, $section, array $variables = array())
 {
     $mainTemplate = in_array($section, array('widget', 'row'));
     if ($mainTemplate && $view->isRendered()) {
         return '';
     }
     $id = '_' . $view->get('proto_id', $view->get('id'));
     $template = $id . $section;
     $renderer = $this->getRenderer();
     if (isset($this->varStack[$template])) {
         $typeIndex = $this->varStack[$template]['typeIndex'] - 1;
         $types = $this->varStack[$template]['types'];
         $this->varStack[$template]['variables'] = array_replace_recursive($this->varStack[$template]['variables'], $variables);
     } else {
         $types = $view->get('types');
         $types[] = $id;
         $typeIndex = count($types) - 1;
         $this->varStack[$template] = array('variables' => array_replace_recursive($view->all(), $variables), 'types' => $types);
     }
     do {
         $types[$typeIndex] .= '_' . $section;
         if (isset($renderer[$types[$typeIndex]])) {
             $this->varStack[$template]['typeIndex'] = $typeIndex;
             $html = $renderer[$types[$typeIndex]]->render($view, $this->varStack[$template]['variables'], $this);
             if ($mainTemplate) {
                 $view->setRendered();
             }
             unset($this->varStack[$template]);
             return $html;
         }
     } while (--$typeIndex >= 0);
     throw new FormException(sprintf('Unable to render the form as none of the following renderer exist: "%s".', implode('", "', array_reverse($types))));
 }
開發者ID:rtznprmpftl,項目名稱:Zikulacore,代碼行數:33,代碼來源:FormRenderer.php


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