Esempio n. 1
0
 /**
  * Form initialization
  */
 public function init()
 {
     $this->loadDefaultDecorators();
     $this->setLegend('New layout');
     $this->addDecorator('fieldset');
     $this->setMethod('POST');
     $element = new Element\Text('title');
     $element->setLabel('Title:')->setRequired(true);
     $this->addElement($element);
     $themes = $this->themesModel->getThemesPaginator(1, 10000);
     $themesList = array();
     foreach ($themes as $theme) {
         $themesList[$theme->getId()] = $theme->getTitle();
     }
     $element = new Element\Select('theme_id');
     $element->setLabel('Theme:')->addMultiOptions($themesList)->setRequired(true);
     $this->addElement($element);
     $element = new Element\Text('name');
     $element->setLabel('Layout file:')->setRequired(true);
     $this->addElement($element);
     $element = new Element\Checkbox('published');
     $element->setLabel('Published:');
     $this->addElement($element);
     if ($this->locator->instanceManager()->hasAlias('sysmap-service')) {
         $navigator = $this->locator->get('sysmap-service')->getMapFormElement();
         if ($navigator instanceof \Zly\Form\Element\Tree) {
             $navigator->setName('map_id');
             $navigator->setMultiple(true);
             $navigator->setRequired();
             $this->addElement($navigator);
         }
     }
     $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')->setIgnore(true);
     $this->addElement($element);
 }
Esempio n. 2
0
 /**
  * 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'));
     }
 }