Re: DB_DataObject_FormBuilder how to delete a record?

From: Date: Fri, 26 Mar 2004 00:38:41 +0000
Subject: Re: DB_DataObject_FormBuilder how to delete a record?
References: 1 2  Groups: php.pear.general 
Request: Send a blank email to pear-general+get-11501@lists.php.net to get a copy of this message
Markus Wolff wrote:
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.
Thanks, that worked! bye Hakan
CU Markus
-- Hakan Kuecuekyilmaz, University of Applied Sciences Esslingen, Germany

« previous php.pear.general (#11501) next »