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


PHP Text::addValidator方法代码示例

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


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

示例1: init

 /**
  * Form initialization
  */
 public function init()
 {
     $this->setMethod('POST');
     $themes = $this->model->getlist();
     $themesList = array();
     foreach ($themes as $theme) {
         $layoutsList = array();
         foreach ($theme->getLayouts() as $layout) {
             $layoutsList[$layout->getId()] = $layout->getTitle();
         }
         $themesList[$theme->getTitle()] = $layoutsList;
     }
     $element = new Element\Select('layout_id');
     $element->setLabel('Theme layout:')->addMultiOptions($themesList)->addDecorator('fieldset')->setRequired(true);
     $this->addElement($element);
     $element = new Element\Text('name');
     $element->setLabel('Widget name:')->setRequired(true);
     $this->addElement($element);
     $element = new Element\Text('placeholder');
     $element->setLabel('Position:')->setRequired(true);
     $this->addElement($element);
     $this->addDisplayGroup(array('placeholder', 'name'), 'place', array('order' => 2, 'legend' => 'Display options:'));
     if ($this->locator->instanceManager()->hasAlias('sysmap-service')) {
         $sysmapElement = $this->locator->get('sysmap-service')->getMapFormElement();
         if (!empty($sysmapElement)) {
             $actionNavigator = clone $sysmapElement;
             if ($actionNavigator instanceof \Zly\Form\Element\Tree) {
                 $actionNavigator->setName('map_id');
                 $actionNavigator->setRequired();
                 $actionNavigator->setLabel('Widget content provider action:');
                 $actionNavigator->addDisableCondition('level', new \Zend\Validator\LessThan(3));
                 $this->addElement($actionNavigator);
             }
             $displayNavigator = clone $sysmapElement;
             if ($displayNavigator instanceof \Zly\Form\Element\Tree) {
                 $displayNavigator->setName('widget_points');
                 $displayNavigator->setLabel('Widget display pages:');
                 $displayNavigator->setRequired();
                 $displayNavigator->setMultiple(true);
                 $this->addElement($displayNavigator);
             }
         }
     }
     $element = new Element\Text('ordering');
     $element->addValidator(new \Zend\Validator\Int())->setRequired(true)->setLabel('Ordering:')->setAttrib('style', 'width:50px;');
     $this->addElement($element);
     $element = new Element\Checkbox('published');
     $element->setLabel('Published:');
     $this->addElement($element);
     $this->addDisplayGroup(array('ordering', 'published'), 'other', array('legend' => 'Publishing options:'));
     $element = new Element\Hidden('module');
     $element->removeDecorator('Label')->removeDecorator('HtmlTag')->setValue($this->_defaultValue);
     $this->addElement($element);
     $element = new Element\Hidden('controller');
     $element->removeDecorator('Label')->setValue($this->_defaultValue)->removeDecorator('HtmlTag');
     $this->addElement($element);
     $element = new Element\Hidden('action');
     $element->removeDecorator('Label')->setValue($this->_defaultValue)->removeDecorator('HtmlTag');
     $this->addElement($element);
     $element = new Element\Submit('submit');
     $element->setLabel('Save');
     $element->setIgnore(true);
     $this->addElement($element);
     foreach ($this->getDisplayGroups() as $group) {
         $group->setDecorators(array('description', 'FormElements', 'fieldset'));
     }
     foreach ($this->getSubForms() as $group) {
         $group->setDecorators(array('description', 'FormElements', 'fieldset'));
     }
 }
开发者ID:zendmaniacs,项目名称:zly-templater,代码行数:73,代码来源:Widget.php


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