Re: New form fields using DB_DO_FormBuilder?
| From: | Anselm Heaton | Date: | Mon, 30 Jan 2006 14:56:53 +0000 |
| Subject: | Re: New form fields using DB_DO_FormBuilder? | ||
| References: | 1 | Groups: | php.pear.general |
| Request: | Send a blank email to pear-general+get-22727@lists.php.net to get a copy of this message | ||
> I´m using DB_DataObject_FormBuilder to create a table form. But I wanna
> create new form fields in this form, as a button, how I do that?
If you use a template to display your forms, then you can add the button in
the template - for instance for a "cancel" button that you would have in all
your forms. Look at the QuickForm documentation on how to use templates
(there are examples in <pear-directory>/doc/HTML_QuickForm/docs/renderers)
If you do not use templates, you can add the button to the QuickForm object
returned by FormBuilder. For instance :
<?php
$fb =& DB_DataObject_FormBuilder::create($tablename);
$form =& $fb->getForm();
// Add a cancel button
$form->addElement('submit', '__cancel__', 'Cancel');
?>
You can also do this directly in your DataObject, by using one of
FormBuilder's callbacks (see http://opensource.21st.de/24.html) :
<?php
class MyObject extends DB_DataObject
{
###START_AUTOCODE
// ...... the generated fields are here
###END_AUTOCODE
// ..... Other fields, such as your FormBuilder settings may be here
/* FormBuilder calls this function once the form has been generated. Use
it to customise your form */
function postGenerateForm(&$form, &$formBuilder) {
// Add a cancel button
$form->addElement('submit', '__cancel__', 'Cancel');
}
}
?>
You should look at the QuickForm documentation
(http://pear.php.net/manual/en/package.html.html-quickform.php) to see what
types of elements you can add.
Anselm
--
------------------------------
Netuxo Ltd
a workers' co-operative
providing low-cost IT solutions
for peace, environmental and social justice groups
and the radical NGO sector
Registered as a company in England and Wales. No 4798478
Registered office: 5 Caledonian Road, London N1 9DY, Britain
------------------------------
email office@netuxo.co.uk
http://www.netuxo.co.uk
------------------------------