fb_booleanFields = $val; } function set_id ($val) { $this->id = $val; } function get_id () { return $this->id ; } function set_title ($val) { $this->title = $val; } function get_title () { return $this->title ; } function set_description ($val) { $this->description = $val; } function get_description () { return $this->description ; } function set_active ($val) { $this->active = $val; } function get_active () { return $this->active ; } function set_file_path ($val) { $this->file_path = $val; } function get_file_path () { return $this->file_path ; } //Begin code taken from http://pear.reversefold.com/dokuwiki/doku.php?id=pear:db_dataobject_formbuilder:beyond_advanced#file_upload_handling // Prepare the form so it contains a file upload field function preGenerateForm(&$fg) { $this->fb_fieldLabels = array ('Image_Path' => 'Choose image to upload'); $this->fb_preDefElements['Image_Path'] = & HTML_QuickForm::createElement('file', 'Image_Path', ('File to upload'), 'maxfilesize=5000000'); } function insert() { if (is_uploaded_file($_FILES['Image_Path']["tmp_name"])) { // You should do some file name checking here, for example disallow spaces etc. $this->Image_Path = $_FILES['Image_Path']["name"]; // I've used a constant "UPLOADDIR" here, which must be defined somewhere of course if (move_uploaded_file($_FILES['Image_Path']["tmp_name"], UPLOADDIR.$this->Image_Path) && chmod(UPLOADDIR.$this->Image_Path, 0644)) { // You could do some additional image manipulation, like scaling, here... return parent::insert(); } } return false; } function delete() { $result = parent::delete(); if ($result) { unlink(UPLOADDIR . $this->Image_Path); } return $result; } // End code taken from FormBuilder wiki // function DataObjects_Jobs() // { // $this->set_fb_booleanFields(array('active')); // } } ?> set_fb_booleanFields(array('active')); //example from doc // Insert "$jobs->get($some_id);" here to edit an // existing object instead of making a new one $fg =& DB_DataObject_FormBuilder::create($jobs); $form =& $fg->getForm(); if ($form->validate()) { $form->process(array(&$fg,'processForm'), false); $form->freeze(); } $form->display(); ?>