Re: FormBuilder Element Group Processing
| From: | Arnaud Limbourg | Date: | Wed, 10 Dec 2003 07:11:49 +0000 |
| Subject: | Re: FormBuilder Element Group Processing | ||
| References: | 1 | Groups: | php.pear.general |
| Request: | Send a blank email to pear-general+get-9445@lists.php.net to get a copy of this message | ||
You can also add an <option> to te select which is NULL => 'No date'.
Ddding the methods
function preGenerateForm(&$fg)
{
}
and/or
function postGenerateForm(&$fg)
{
}
You can add elements previous to the form creation
example is, it predefines some form elements
function preGenerateForm(&$fg)
{
$this->fieldLabels = array(
'nom' => 'Nom',
'prenom' => 'Prénom',
'handle' => 'Login'
);
$el = array();
$el['is_active'] =& HTML_QuickForm::createElement('select', 'is_active', 'Ce compte est-il actif ?',
array('Y' => 'OUI',
'N' => 'NON'
), array('size' => 2)
);
$el['fonction'] =& HTML_QuickForm::createElement('select', 'fonction', 'Fonction',
array('employee' => 'Employee',
'NULL' => 'Autre'
), array('size' => 4)
);
$el['auth_user_id'] =& HTML_QuickForm::createElement('hidden', 'auth_user_id');
$this->preDefElements = $el;
$this->preDefOrder = array(
'prenom', 'nom', 'handle', 'passwd', 'email', 'telephone',
'mobile', 'bureau', 'fonction', 'is_active',
'lastlogin', 'auth_user_id',
'datecrea', 'demandepass', 'lettrecache'
);
}
Hi, This is my first time posting to this list, I hope I'm going about it the right way. I am in a situation where I have used FormBuilder to generate a form of which two elements are dates. Now I have defined them as such in the DataObject so they appear as pop-up selects in the HTML page. My problem is that I would like to give the possibility of not entering a date (i.e. NULL value) and I haven't figured out an efficient solution yet. My thoughts are to create an element group containing a date value and a checkbox, if the checkbox isn't set the date selects would be disabled (via javascript.) To do this I need to 1) Add the group to the form and replace the existing date fields 2) add form processing that determines whether checkbox is on or off and determines whether to set date to NULL or not 3) write the javascript Could you share with me your opinions on the best methods for accomplishing 1 and 2? For example, should I override the getForm() method or can I replace the particular elements with groups in another manner? Very much appreciated, Orya