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


PHP FormView::getVars方法代码示例

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


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

示例1: buildView

 public function buildView(FormView $view, FormInterface $form)
 {
     $repo = $this->em->getRepository($form->getAttribute('class'));
     $nodeEmpty[] = array('id' => null, 'title' => 'Aucun', 'icon' => null, '__children' => null);
     $treeNodes = $repo->childrenHierarchy(null, false, array('decorate' => false));
     $treeArray = array_merge($nodeEmpty, $treeNodes);
     $treeHtml = $this->createHtmlTree($treeArray, 0);
     $vars = $view->getVars();
     $value = $vars['value'];
     if ($value != null) {
         $selectedNode = $repo->find($value);
         $treepath = $this->getTreePath($selectedNode);
     } else {
         $treepath = '/';
     }
     $view->set('configs', $form->getAttribute('configs'))->set('class', $form->getAttribute('class'))->set('property', $form->getAttribute('property'))->set('treeHtml', $treeHtml)->set('treePath', $treepath);
 }
开发者ID:r4cker,项目名称:lowbi,代码行数:17,代码来源:TreeType.php

示例2: 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->getVar('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->getVar('types');
         $types[] = $view->getVar('full_block_name');
         $typeIndex = count($types) - 1;
         $variables = array_replace_recursive($view->getVars(), $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 trim($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:nathanlon,项目名称:symfony,代码行数:55,代码来源:FormHelper.php

示例3: buildView

 /**
  * {@inheritdoc}
  */
 public function buildView(FormView $view, FormInterface $form)
 {
     $items = $form->getClientData();
     $deleteForm = array();
     $showForm = array();
     $formVars = $view->getVars();
     $fieldTypeName = $formVars['name'];
     if ($form->getAttribute('searchForm') == null) {
         $metaClass = $this->em->getClassMetadata($form->getAttribute('entityName'))->rootEntityName;
         $formType = str_replace('Entity', 'Form', $metaClass) . 'SearchType';
     } else {
         $formType = $form->getAttribute('searchForm');
     }
     $entityForm = $this->formFactory->create(new $formType());
     $columns = array();
     $columnsType = array();
     $columnsLabels = null;
     $itr = 0;
     if ($form->getAttribute('columns') == null) {
         foreach ($entityForm as $field) {
             if ($field->getName() != '_token') {
                 if ($itr >= 4) {
                     break;
                 }
                 $type = $this->lowbiSystem->guessFormFieldType($field);
                 $columns[] = $field->getName();
                 $columnsType[] = $type;
                 $columnsLabels[$field->getName()] = $field->getAttribute('label');
                 $itr++;
             }
         }
     } else {
         foreach ($entityForm as $item) {
             if (in_array($item->getName(), $form->getAttribute('columns'))) {
                 $label = $item->getAttribute('label');
                 if (!$label) {
                     $label = $item->getName();
                 }
                 $columnsLabels[$item->getName()] = $item->getAttribute('label');
             }
         }
         $columns = $form->getAttribute('columns');
         $columnsType = $form->getAttribute('columnsType');
     }
     if ($items != '' || $items != null) {
         $deleteForm[$items->getId()] = $this->createDeleteForm($items->getId(), $fieldTypeName)->createView();
         $showForm[$items->getId()] = $this->createShowForm($items->getId())->createView();
     }
     if ($form->getParent()->getClientData() != null) {
         if ($form->getParent()->getClientData()->getId() != null) {
             if (is_array($form->getClientData()) || is_object($form->getParent()->getClientData())) {
                 $sourceEntityId = $form->getParent()->getClientData()->getId();
                 $sourceEntityName = $this->getBundleName(get_class($form->getParent()->getClientData()));
             } else {
                 $sourceEntityId = $form->getClientData()->getOwner()->getId();
                 $sourceEntityName = $this->getBundleName(get_class($form->getClientData()->getOwner()));
             }
         } else {
             $sourceEntityId = null;
             $sourceEntityName = $this->getBundleName(get_class($form->getParent()->getClientData()));
         }
     } else {
         $sourceEntityId = null;
         $sourceEntityName = null;
     }
     //Create search form attributes
     $searchFormName = $formType;
     $searchForm = $this->formFactory->create(new $searchFormName());
     foreach ($searchForm as $field) {
         $type = $this->lowbiSystem->guessFormFieldType($field);
         if ($type == 'Date') {
             $oldField = $field;
             $searchForm->offsetUnset($field->getName());
             $label = $oldField->getAttribute('label');
             if (!$label) {
                 $label = $oldField->getName();
             }
             $exForm = $this->formFactory->createNamedBuilder('form', $oldField->getName(), null, array('label' => $label))->add($oldField->getName() . '_start', 'lowbi_date', array('label' => ' '))->add($oldField->getName() . '_end', 'lowbi_date', array('label' => ' '))->getForm();
             $searchForm->add($exForm);
         }
     }
     $extraForm = $this->createSearchForm($form, $fieldTypeName, $columns, $columnsType);
     $searchForm->add($extraForm);
     //disable actions when entire form is read only
     if ($form->getParent()->isReadOnly() || $sourceEntityId == null) {
         $actions = array('select' => false, 'remove' => false);
     } else {
         $actions = $form->getAttribute('actions');
     }
     $view->set('configs', $form->getAttribute('configs'))->set('columns', $columns)->set('columnsType', $columnsType)->set('columnsLabel', $columnsLabels)->set('actions', $actions)->set('sourceEntityName', $sourceEntityName)->set('sourceEntityId', $sourceEntityId)->set('entityName', $form->getAttribute('entityName'))->set('searchForm', $searchForm->createView())->set('deleteForm', $deleteForm)->set('showForm', $showForm)->set('items', $items);
 }
开发者ID:r4cker,项目名称:lowbi,代码行数:94,代码来源:SearchSelectType.php

示例4: renderBlock

 protected function renderBlock(FormView $view, $blockName = null, array $variables = array())
 {
     $variables = $view->getVars();
     $type = null;
     foreach ($variables['block_prefixes'] as $blockPrefix) {
         if (in_array($blockPrefix, array('textarea', 'email', 'integer', 'money', 'number', 'password', 'percent', 'search', 'url', 'hidden', 'collection', 'choice'))) {
             $type = $blockPrefix;
         }
     }
     if ('rest' == $blockName) {
         return $this->renderFormRest($view, $blockName, $variables);
     }
     switch ($type) {
         // Text fields
         case 'textarea':
             return $this->renderTextareaWidget($view, $blockName, $variables);
         case 'email':
             return $this->renderEmailWidget($view, $blockName, $variables);
         case 'integer':
             return $this->renderIntegerWidget($view, $blockName, $variables);
         case 'money':
             return $this->renderMoneyWidget($view, $blockName, $variables);
         case 'number':
             return $this->renderNumberWidget($view, $blockName, $variables);
         case 'password':
             return $this->renderPasswordWidget($view, $blockName, $variables);
         case 'percent':
             return $this->renderPercentWidget($view, $blockName, $variables);
         case 'search':
             return $this->renderSearchWidget($view, $blockName, $variables);
         case 'url':
             return $this->renderUrlWidget($view, $blockName, $variables);
         case 'hidden':
             return $this->renderHiddenWidget($view, $blockName, $variables);
         case 'collection':
             return $this->renderCollectionWidget($view, $blockName, $variables);
         case 'choice':
             return $this->renderChoiceWidget($view, $blockName, $variables);
     }
     switch ($blockName) {
         case 'widget':
             return $this->renderFormWidget($view, $blockName, $variables);
         case 'row':
             return $this->renderFormRow($view, $blockName, $variables);
     }
     throw new \Exception(__METHOD__ . ' Oups ' . $view->getName() . ' // ' . $blockName . ' // ' . $blockNameSuffix);
 }
开发者ID:rpg600,项目名称:FSCRestBundle,代码行数:47,代码来源:FormNormalizer.php


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