当前位置: 首页>>代码示例>>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;未经允许,请勿转载。