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


PHP FormInterface::prepare方法代码示例

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


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

示例1: __invoke

 /**
  * Outputs message depending on flag
  *
  * @param FormInterface $form
  * @param array         $staticElements
  * @param null          $formClass
  *
  * @return string
  */
 public function __invoke(FormInterface $form, array $staticElements = [], $formClass = null)
 {
     $submitElements = [];
     /** @var Form $form */
     $form->setAttribute('role', 'form');
     if ($formClass == 'form-inline') {
         $form->setAttribute('class', $formClass . ' pull-right');
     } elseif ($formClass) {
         $form->setAttribute('class', $formClass);
     } else {
         $formClass = $form->getAttribute('class');
     }
     $form->prepare();
     $output = $this->getView()->form()->openTag($form);
     foreach ($staticElements as $element) {
         $viewModel = new ViewModel();
         $viewModel->setVariable('label', $element['label']);
         $viewModel->setVariable('value', $element['value']);
         $viewModel->setTemplate('travello-view-helper/widget/bootstrap-form-static');
         $output .= $this->getView()->render($viewModel);
     }
     list($output, $submitElements) = $this->renderElements($form, $formClass, $output, $submitElements);
     if ($formClass == 'form-inline') {
         $template = 'bootstrap-form-submit-inline';
     } else {
         $template = 'bootstrap-form-submit';
     }
     $viewModel = new ViewModel();
     $viewModel->setVariable('submitElements', $submitElements);
     $viewModel->setTemplate('travello-view-helper/widget/' . $template);
     $output .= $this->getView()->render($viewModel);
     $output .= $this->getView()->form()->closeTag();
     return $output;
 }
开发者ID:RalfEggert,项目名称:travello-view-helper,代码行数:43,代码来源:BootstrapForm.php

示例2: __construct

 /**
  * @param FormInterface $form
  * @param RendererInterface $renderer
  */
 public function __construct(FormInterface $form, RendererInterface $renderer)
 {
     $this->form = $form;
     if ($form instanceof ZendForm) {
         $form->prepare();
     }
     $this->renderer = $renderer;
 }
开发者ID:hanif,项目名称:stokq,代码行数:12,代码来源:Form.php

示例3: __invoke

 /**
  * Outputs message depending on flag
  *
  * @return string
  */
 public function __invoke(FormInterface $form, $class = 'form-horizontal')
 {
     $submitElements = [];
     $form->setAttribute('class', $class . ' well');
     $form->setAttribute('role', 'form');
     $form->prepare();
     $output = $this->getView()->form()->openTag($form);
     foreach ($form as $element) {
         if ($element instanceof Submit || $element instanceof Button) {
             $submitElements[] = $element;
         } elseif ($element instanceof Csrf || $element instanceof Hidden) {
             $output .= $this->getView()->formElement($element);
         } elseif ($element instanceof Collection) {
             $output .= $this->getView()->formCollection($element);
         } elseif ($element instanceof Checkbox) {
             // setup view model
             $viewModel = new ViewModel();
             $viewModel->setVariable('element', $element);
             $viewModel->setTemplate('zf2rapid-library/widget/bootstrap-form-checkbox');
             // render form element
             $output .= $this->getView()->render($viewModel);
         } else {
             $element->setAttributes(['class' => 'form-control']);
             $element->setLabelAttributes(['class' => 'col-sm-2 control-label']);
             // setup view model
             $viewModel = new ViewModel();
             $viewModel->setVariable('element', $element);
             $viewModel->setTemplate('zf2rapid-library/widget/bootstrap-form-group');
             // render form element
             $output .= $this->getView()->render($viewModel);
         }
     }
     // setup view model
     $viewModel = new ViewModel();
     $viewModel->setVariable('submitElements', $submitElements);
     $viewModel->setTemplate('zf2rapid-library/widget/bootstrap-form-submit');
     // render submit elements
     $output .= $this->getView()->render($viewModel);
     $output .= $this->getView()->form()->closeTag();
     return $output;
 }
开发者ID:zfrapid,项目名称:zf2rapid-library,代码行数:46,代码来源:BootstrapForm.php


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