Customizing DB DataObject and FormBuilder

From Web Developer Network Wiki
Jump to: navigation, search

Common customization options for DB_DataObject:

Adding a submit date & time to the record:

	var $fb_formHeaderText		= "Space Request Form";
	var $fb_textFields			= array('Description','OtherBuilding','ProposedUse','SpaceVacated','Comments');
	var $fb_fieldLabels = array('CampusAddress'=>'Campus Address');

	function preGenerateForm(&$formBuilder) {
		$this->fb_preDefElements['submitdatetime'] = HTML_QuickForm::createElement('hidden','submitdatetime');
	}

	function postGenerateForm(&$form,&$formBuilder) {
		/* add headings for form sections */
		$el =& HTML_QuickForm::createElement('header',"myheader","Information on this section");
		$form->insertElementBefore($el,'submitdatetime');
		unset($el);
		$el =& $form->getElement('comments');
		$el->setCols(70);
		$el->setRows(5);
	}

        function insert() {
		$this->submitdatetime = date('Y-m-d H:i:s');
		return parent::insert();
	}
Personal tools
Namespaces

Variants
Actions
Navigation
Toolbox