'date DESC'); protected function _bindListColumns($list) { $list->addColumn('no', 'no') ->addColumn('date', 'date', array('orderBy' => 'date')) ->addColumn('image', 'image') ->addColumn('item', 'item', array('attribs' => array('width' => 400, 'valign' => 'top'))) ->addColumn( 'link_enum', 'featured', array('orderBy' => 'featured', 'attribs' => array('width' => 100, 'align' => 'center'), 'values' => array('y' => 'Yes', 'n' => 'No'))) ->addColumn('options', 'options'); return $this; } protected function _bindFormFields($form) { $form->addElement('date', 'date', array('label' => 'Publication Date', 'required' => true)); $form->addElement('text', 'title', array('label' => 'News Title', 'required' => true)); $form->addElement('extendedImage', 'image', array('label' => 'Image', 'required' => false)); $form->addElement('textarea', 'introduction', array('label' => 'Introduction', 'rows' => 5)); $form->addElement('htmlEditor', 'content', array('label' => 'Content', 'required' => true)); $form->image->addValidator('File_IsImage'); $form->addElement( 'radio', 'linkType', array('label' => 'Type', 'multiOptions' => array('none' => 'No Link', 'url' => 'URL', 'cms' => 'Site Page', 'file' => 'File'), 'required' => true, 'separator' => ' | ', 'onclick' => 'this.blur()', 'onchange' => "$('#fieldset-linkTypeGroup>dl:first').attr('class', this.value);") ); $form->addElement( 'text', 'url', array('label' => 'Url', 'class' => 'text', 'filters' => array('StringTrim'), 'validators' => array('Url'), 'description' => 'Example: http://www.google.com') ); $form->addElement( 'select', 'idPage', array('label' => 'Site Page', 'escapeLabel' => false, 'multiOptions' => array('' => '- Select Page -') + App_Cms_Obj::getInstance()->getParent4Select(0)) ); $form->addElement('extendedFile', 'file', array('label' => 'File')); $linkType = $this->_getData('linkType', 'none'); switch ($linkType) { case 'url': $form->url->setRequired(true); break; case 'cms': $form->idPage->setRequired(true); break; case 'file': $form->file->setRequired(true); break; } $form->addDisplayGroup( array('linkType', 'url', 'idPage', 'file'), 'linkTypeGroup', array('legend' => 'Link') ); $form->linkTypeGroup->getDecorator('HtmlTag')->setOption('class', $linkType); $form->addElement( 'checkbox', 'featured', array( 'label' => 'Featured', 'checkedValue' => 'y', 'uncheckedValue' => 'n', 'decorators' => array( 'ViewHelper', array(array('topLabel' => 'Label'), array('placement' => 'APPEND', 'label' => 'Mark this item as featured item')), array('HtmlTag', array('tag' => 'dd', 'id' => 'featured-element')), array(array('rightLabel' => 'Label'), array('placement' => 'PREPEND', 'tag' => 'dt')), ) ) ); return $this; } protected function _doNew() { $form = $this->_getNewForm(); $data = array('date' => date('Y-m-d'), 'linkType' => 'none'); $form->setDefaults($data); $this->_renderMainForm($form); } protected function _renderMainForm($form) { $this->doc->addStylesheet('css/admin-news.css'); return parent::_renderMainForm($form); } }