Re: Re: QuickForm & Set Defaults onBlur OK
| From: | Jacques | Date: | Fri, 13 Aug 2004 06:00:21 +0000 |
| Subject: | Re: Re: QuickForm & Set Defaults onBlur OK | ||
| References: | 1 2 | Groups: | php.pear.general |
| Request: | Send a blank email to pear-general+get-14093@lists.php.net to get a copy of this message | ||
Jacques Nunes wrote:
Jacques wrote:The last line correct is: (without the a $mat) $form->setDefaults(array('matUsuario' => '') ); // after type the mat (ID)Hi people, I have a quickform that have a text called user_id, user_name and user_fone. When I type a id number, in the textfield, and after I press tab (onBlur of user_id), for go to next textfield (id_name), i like to return the user_name and user_fone from DB_DataObject, if it exists. I have to submit the form and get(id) to setDefaults? How make this? Thanks!Hi people, It,s time of my litle contribute! This is my solution to auto fill the fields in onBlur event via simple request with js enable: (Ps: $usuario is the DataObject, $form is a QuickForm and $mat is a ID) Code to QuickForm: ........................................................................ $form->addElement('text', 'matUsuario', 'Matrícula: ', array('onBlur' => 'location=\'/www/demo/?action=setDemo&mat=\'+matUsuario.value')); ........................................................................ ...this produce a javascript redirect to: /www/demo/?action=setDemo&mat={value_of_matUsuario_field} ...then I recover de value with $_Request['mat']... ........................................................................ $mat = $_Request['mat']; ........................................................................ ... and check... ........................................................................ if ($mat) {// - If there is a objectUser with the $mat (ID) if ($usuario->get('matUsuario', $mat)) { // recover de dataObject attributes to set the form; // update... $form->setDefaults($usuario->toArray()); } else { // Don´t have a user with the $mat (ID) // recover the value of request to field matUsuario (ID) // insert... $form->setDefaults(array('matUsuario'=>$mat)); }} else { // But if is the first access on the page (/www/demo/?action=setDemo) without a $mat (&mat=234) then it´s a insert...$form->setDefaults(array('matUsuario' => $mat) ); // after type the mat (ID) }........................................................................ Is this. Jacques, from Florianópolis, SC, Brazil. Oops: