Re: QuickForm question regarding submit values...
| From: | Brent Cook | Date: | Sat, 07 Sep 2002 04:16:05 +0000 |
| Subject: | Re: QuickForm question regarding submit values... | ||
| References: | 1 | Groups: | php.pear.general |
| Request: | Send a blank email to pear-general+get-2258@lists.php.net to get a copy of this message | ||
On Mon, 19 Aug 2002, R. Cole wrote:
>
> I've been trying to read the code of QuickForm.php in order to understand
> how the addElement('submit') selection works. I'm trying to set it so
> that if someone clicks the "yes" option in a form, it will continue on
> (delete a record), but if someone clicks no, it will take them back to the
> referring menu. Is there any easy way to do this?
>
> thanks,
> Rob
I'd do something like this:
$dialog_widget['ok'] =
&HTML_QuickForm::createElement('submit','answer','Ok');
$dialog_widget['cancel'] =
&HTML_QuickForm::createElement('submit','answer','Cancel');
$form = new HTML_QuickForm('whatever', 'POST', './this_file');
$answer=$_REQUEST['answer']
switch ($answer) {
case 'Ok':
$result = $db->delete('thing');
if (PEAR::isError($result)) {
$form->addData('There has been a problem '.
<pre>'.$result->getMessage().'</pre>');
} else {
$form->addData('<p>The thing has been deleted.</p>');
}
break;
case 'Cancel':
$form->addData('<p>Canceled delete</p>')
$redirect_uri = '?uri=album.php';
break;
default:
$form->addData('<b>Really delete the album?</b>');
$form->addElementGroup($dialog_widget);
}
echo $form->toHTML();
Doing the addElementGroup just puts the two submit buttons next to each
other (though that's changeable too.)
- Brent