'added DESC', 'defaultIpp' => 20); protected $_formDefaults = array( 'typePage' => 'all', 'showInMenu' => 'y', 'showOnPage' => 'y', ); protected function _bindListColumns($list) { $list->addColumn('no', 'no') ->addColumn('text', 'title', array('orderBy' => 'title', 'title' => 'Title')) ->addColumn('file', 'file', array('title' => 'File')) ->addColumn('link_enum', 'showInMenu', array( 'title' => 'Show in Menu', 'orderBy' => 'showInMenu', 'values' => array( 'n' => 'No', 'y' => 'Yes') )) ->addColumn('link_enum', 'showOnPage', array( 'title' => 'Show on Page', 'orderBy' => 'showOnPage', 'values' => array( 'n' => 'No', 'y' => 'Yes') )) ->addColumn('page_list', 'pageList', array('title' => 'Show on pages', 'attribs' => array('valign' => 'top'))) ->addColumn('options', 'options'); return $this; } protected function _bindFormFields($form) { $form->addElement('text', 'title', array('label' => 'Title', 'required' => true)); $form->addElement('extendedFile', 'file', array('label' => 'File', 'required' => true)); $form->addElement( 'checkbox', 'showInMenu', array( 'label' => 'Show In Menu', 'checkedValue' => 'y', 'uncheckedValue' => 'n', ) ); $form->addElement( 'checkbox', 'showOnPage', array( 'label' => 'Show On Page', 'checkedValue' => 'y', 'uncheckedValue' => 'n', ) ); $form->addElement( 'multiCheckbox', 'idPage', array( 'label' => 'Show At', 'columns' => 3, 'multiOptions' => $this->dataObj->getSitePage(0) ) ); return $this; } protected function _doNew() { $form = $this->_getNewForm(); $form->idPage->setRequired(); $form->setDefaults($this->getFormDefaults()); $this->_renderMainForm($form); } protected function _doEdit() { $form = $this->_getEditForm(); $form->idPage->setRequired(); $this->dataObj->initData(); $data = $this->_getData4Form($form); $form->setDefaults($data); $this->_renderMainForm($form); } protected function _doInsert() { $form = $this->_getNewForm(); if (Qs_Request::getRequestValue('showOnPage') == 'y' || Qs_Request::getRequestValue('showInMenu') == 'y') { $form->idPage->setRequired(); } if ($form->validate()) { $this->_initFromForm($form); if (($e = $this->dataObj->insert()) instanceof Exception ) { Qs_Debug::processException($e); } else { $this->_postInsert(); $this->_setBackMessage(Qs_ViewController::MSG_ADDED); } $this->_doBack(); } else { $this->_renderMainForm($form); } return $this; } protected function _doInsertAjax() { $form = $this->_getNewForm(); if (Qs_Request::getRequestValue('showOnPage') == 'y' || Qs_Request::getRequestValue('showInMenu') == 'y') { $form->idPage->setRequired(); } $this->_validateAjax($form); } protected function _doUpdate() { $form = $this->_getEditForm(); if (Qs_Request::getRequestValue('showOnPage') == 'y' || Qs_Request::getRequestValue('showInMenu') == 'y') { $form->idPage->setRequired(); } if ($form->validate()) { $this->_initFromForm($form); if (($e = $this->dataObj->update()) instanceof Exception ) { Qs_Debug::processException($e); } else { $this->_postUpdate(); $this->_setBackMessage(Qs_ViewController::MSG_UPDATED); } $this->_doBack(); } else { $this->_renderMainForm($form); } return $this; } protected function _doUpdateAjax() { $form = $this->_getEditForm(); if (Qs_Request::getRequestValue('showOnPage') == 'y' || Qs_Request::getRequestValue('showInMenu') == 'y') { $form->idPage->setRequired(); } $this->_validateAjax($form); } protected function _renderMainForm($form) { $this->doc->addScript('js/app/app-file-form.js') ->addInitFunction('initAppFileForm'); return parent::_renderMainForm($form); } }