addElement('text', 'doc_name', 'Course Name'); $form->addElement('text', 'doc_number', 'Course ID', array('maxlength' => 16)); $renewal_date = $form->createElement('calendar', 'renewal_date', 'Renewal Date'); $renewal_date->_options['addEmptyOption'] = true; $form->addElement($renewal_date); $form->addElement('text', 'ce_hours', 'CE Credits'); $form->addElement('select', 'status_id', 'Course Status', array('' => 'Select One') + (array) $this->DBObj->get4Select('DEventDocStatus')); $form->setDefaults($this->DBObj->getData()); $form->addFormRule(array(&$this, 'validForm')); $form->addRuleRequired(array('doc_number','doc_name')); return $form; } function validForm($fields) { if (!$this->DBObj->isNumberUnique($fields['doc_number'])) { return array('doc_number' => 'The Document Number must be unique'); } return true; } function _doListBind(DB_List $list) { $list->insertColLast( 'doc_number', array( 'title' => 'Course ID', 'order_by' => 'doc_number', 'tpl' => DB_LIST_CELL_TEXT_CENTER, 'params' => array('doc_number') ) ); $list->insertColLast( 'doc_name', array( 'title' => 'Course Name', 'order_by' => 'doc_name', 'tpl' => DB_LIST_CELL_TEXT, 'params' => array('doc_name') ) ); $list->insertColLast( 'ce_hours', array( 'title' => 'CE Credits', 'order_by' => 'ce_hours', 'tpl' => DB_LIST_CELL_TEXT_CENTER, 'params' => array('ce_hours') ) ); $list->insertColLast( 'events_count', array( 'title' => 'Events Count', 'order_by' => 'events_count', 'tpl' => DB_LIST_CELL_TEXT_CENTER, 'params' => array('events_count') ) ); $list->insertColLast( 'renewal_date', array( 'title' => 'Renewal Date', 'order_by' => 'renewal_date', 'tpl' => DB_LIST_CELL_DATE, 'params' => array('renewal_date') ) ); $list->addOptionsColumn('options'); } function doNew() { $form = $this->_getNewForm(); $form->setDefaults(array('renewal_date' => mktime())); $form->exec(); } }