Re: QF & FB duplicate form element
| From: | Robert Munteanu | Date: | Sun, 16 Oct 2005 16:10:16 +0000 |
| Subject: | Re: QF & FB duplicate form element | ||
| References: | 1 | Groups: | php.pear.general |
| Request: | Send a blank email to pear-general+get-21503@lists.php.net to get a copy of this message | ||
Jorge wrote:
Hi guys!
I'm getting crazy about the following error working with QuickForm + FrontBuilder for a sign up form.
As usual, login / passwd are shown in form by FB:
<code>
[......]
$auth = DB_DataObject::factory('auth');
$fb_auth =& DB_DataObject_FormBuilder::create($auth);
$frm_auth =& $fb_auth->getForm();
$auth->postGenerateForm(&$frm_auth,&$fb_auth);
[....]
</code>
I need user retypes password, then I added postGenerateForm() function within Auth class. I also added preProcessForm() for encrypt passwd and it works.
<code>
[.....]
function postGenerateForm(&$form,&$fb) {
// FALLA!! Repite dos veces el campo
$form->addElement('password', 'passwordR', 'Retype password', array('size'=>32, 'maxlenght'=>32));
$form->addRule('passwordR', 'Retype password', 'required');
$form->addRule(array('password', 'passwordR'), 'Password does not match.', 'compare');
}
function preProcessForm(&$data) {
if(isset($data['password'])) {
if($data['password'] != $this->password) {
$data['password'] = md5($data['password']);
}
}
//igualar id_user(auth) e id_user(users)
}
[....]
</code>
I think this should be work fine but text element passwordR is shown three times instead two. If postGenerateForm() is not called then only one password element is shown. Does anybody know why?
thansks
Please see http://opensource.21st.de/25.html#A3 for some pointers. Hint: you're adding the element to the form. You should be preloading it.
Robert