Re: DB_DataObject_FormBuilder how to delete a record?
| From: | Markus Wolff | Date: | Thu, 25 Mar 2004 16:49:01 +0000 |
| Subject: | Re: DB_DataObject_FormBuilder how to delete a record? | ||
| References: | 1 | Groups: | php.pear.general |
| Request: | Send a blank email to pear-general+get-11494@lists.php.net to get a copy of this message | ||
Hakan Kücükyilmaz schrieb:
I am new to FormBuilder. I tried the example in the package and now I would like to add a delete-button to the form. How can I achieve this?Hi Hakan, well, you'll have to add the delete button and react to it manually. FormBuilder does not handle deletes automatically. A possibility would be to define a postGenerateForm() method in your DataObject-derived class where you add the button: function postGenerateForm(&$form) {
$form->addElement('submit', 'Delete', 'Delete');
}
Then, in your main script, you have to check if this was the submit button that was pressed and then delete the object:
if (isset($_POST['Delete'])) {
$myDataObject->delete();} Of course, the DataObject's primary key field needs to be set first. CU Markus