'image', 'linkType' => 'none', 'show' => 'y', ]; protected function _initElements() { $dataObj = new App_Slide_Admin_Obj(); $config = Qs_Application::getConfig('slide')->toArray(); $this->addElement('text', 'title', ['label' => 'Title', 'required' => true]); $type = $this->_getData('type'); $this->addElement( 'select', 'type', [ 'label' => 'Type', 'multiOptions' => $dataObj->getDSlideType4Select(), 'required' => true, 'value' => $type, 'separator' => ' ', ] ); $this->addElement( 'htmlEditor', 'html', [ 'label' => 'HTML Content', 'toolbar' => 'Basic', 'required' => (!$this->isSubmitted() || 'html' == $type), ] ); $this->addElement( 'extendedImage', 'image', [ 'label' => 'Slide Image', 'required' => (!$this->isSubmitted() || 'image' == $type), 'resize' => $config['image']['width'] . 'x' . $config['image']['height'] . $config['image']['resizeMethodAlias'], 'validators' => [ ['IsImage', true], [ 'ImageSize', true, [ 'minwidth' => $config['image']['width'], 'minheight' => $config['image']['height'], ], ], ], ] ); $this->addElement( 'extendedImage', 'backgroundImage', [ 'label' => 'Background Image', 'required' => false, 'resize' => $config['image']['width'] . 'x' . $config['image']['height'] . $config['image']['resizeMethodAlias'], 'validators' => [ ['IsImage', true], [ 'ImageSize', true, [ 'minwidth' => $config['image']['width'], 'minheight' => $config['image']['height'], ], ], ], ] ); $linkType = $this->_getData('linkType'); $this->addElement( 'select', 'linkType', [ 'label' => 'Type', 'multiOptions' => ['none' => 'No Link', 'url' => 'URL', 'cms' => 'Site Page'], 'required' => true, 'value' => $linkType, 'separator' => ' ', ] ); $this->addElement( 'text', 'url', [ 'label' => 'Url', 'class' => 'text', 'description' => 'Example: ' . constant('EXAMPLE_URL'), ] ); if ($linkType == 'url') { $this->getElement('url')->addValidator('url'); } $this->addElement('text', 'linkText', ['label' => 'Link Text', 'class' => 'text']); $this->addElement('select', 'pageId', ['label' => 'Site Page', 'escapeLabel' => false]); $this->pageId->setMultiOptions(['' => '- Select Page -'] + App_Cms_Obj::getInstance()->getPages4Select()); $this->addDisplayGroup( ['linkType', 'url', 'pageId', 'linkText'], 'linkTypeGroup', ['legend' => 'Link'] ); $this->getDisplayGroup('linkTypeGroup')->getDecorator('HtmlTag')->setOption('class', $linkType); $this->addElement('checkbox', 'show', ['label' => 'Show on user end', 'decoration' => 'simple']); foreach (['url', 'linkText', 'pageId', 'image'] as $element) { $this->{$element}->getDecorator('Label')->setOption('class', 'required'); } if (in_array($linkType, ['url', 'cms'])) { if (App_Slide_View::HTML_TYPE == $type) { $this->getElement('linkText')->setRequired(); } if ('url' == $linkType) { $this->getElement('url')->setRequired(); } else if ('cms' == $linkType) { $this->getElement('pageId')->setRequired(); } } } public function render(Zend_View_Interface $view = null) { /** * спочатку робиться рендер щоб ініціалізувалась форма і підчепились джаваскрипти, бо з App_Slide.updateQsForm() * робляться звернення до Qs_Form */ $content = parent::render($view); /** @var $doc Qs_Doc */ $doc = Zend_Registry::get('doc'); $doc->addScript('js/app/admin-slide.js'); $options = ['formId' => $this->getId()]; $doc->addInitFunction('initAppSlide', [$options]); return $content; } }