_dataObj) { $this->_dataObj = new WideSlide\Admin\Obj(); } return $this->_dataObj; } protected function _initElements() { $config = \Qs_Application::getConfig('WideSlide')->toArray(); $this->addElement('text', 'title', array('label' => 'Title', 'required' => true)); $this->addElement( 'select', 'pageId', array( 'label' => 'Slide Page', 'required' => true, 'multiOptions' => array('' => '- Select One -') + (array) $this->_getDataObj()->getSliderPages() ) ); if ($this->_getData('pageId') && WideSlide\AbstractObj::HOME_PAGE_ID != $this->_getData('pageId')) { $resize = $config['imageAdditionalPages']['width'] . 'x' . $config['imageAdditionalPages']['height'] . $config['imageAdditionalPages']['resizeMethodAlias']; $minWidth = $config['imageAdditionalPages']['width']; $minHeight = $config['imageAdditionalPages']['height']; } else { $resize = $config['image']['width'] . 'x' . $config['image']['height'] . $config['image']['resizeMethodAlias']; $minWidth = $config['image']['width']; $minHeight = $config['image']['height']; } $validators = array( array('IsImage', true), array( 'ImageSize', true, array( 'minwidth' => $minWidth, 'minheight' => $minHeight ) ) ); $this->addElement( 'extendedImage', 'image', array( 'label' => 'Image', 'required' => true, 'resize' => $resize, 'validators' => $validators ) ); $this->addElement('checkbox', 'enabled', array('label' => 'Show on user end', 'decoration' => 'simple')); return $this; } /** * @param array|string $elementsNames * @return AbstractForm */ protected function _addAsterisk($elementsNames) { if (!is_array($elementsNames)) { $elementsNames = array($elementsNames); } foreach ($elementsNames as $elementName) { $element = $this->getElement($elementName); if (!$element->isRequired()) { $element->getDecorator('Label')->setOption('class', 'required'); } } return $this; } /** * @param array|string $elementsNames * @return AbstractForm */ protected function _addHiddenClass($elementsNames) { if (!is_array($elementsNames)) { $elementsNames = array($elementsNames); } foreach ($elementsNames as $elementName) { $element = $this->getElement($elementName); /** @var \Qs_Form_Decorator_Label $label */ $label = $element->getDecorator('Label'); $label->setTagOption('class', 'hidden'); /** @var \Qs_Form_Decorator_HtmlTag $htmlTag */ $htmlTag = $element->getDecorator('HtmlTag'); $htmlTag->setOption('class', 'hidden'); } return $this; } public function render(\Zend_View_Interface $view = null) { /** @var \Qs_Doc $doc */ $doc = \Zend_Registry::get('doc'); $doc->addScript('js/app/wideSlide/admin/form.js'); $config = \Qs_Application::getConfig('WideSlide')->toArray(); $options = array( 'form' => $this->getId(), 'pageElementId' => 'pageId', 'homePageId' => WideSlide\AbstractObj::HOME_PAGE_ID, 'defaultImgSize' => $config['image']['width'] . 'x' . $config['image']['height'], 'imgSize' => $config['imageAdditionalPages']['width'] . 'x' . $config['imageAdditionalPages']['height'] ); $doc->addInitObject('App_WideSlide_Admin_Form', array($options), 'wideSlideFrom'); return parent::render($view); } }