Re: [HTML Quickform] addElement(-,-,-, array('value' => ... doesn't work

From: Date: Thu, 29 Sep 2005 06:56:30 +0000
Subject: Re: [HTML Quickform] addElement(-,-,-, array('value' => ... doesn't work
References: 1  Groups: php.pear.general 
Request: Send a blank email to pear-general+get-21142@lists.php.net to get a copy of this message
Hi, Damien Cros wrote:
This is just an example. The user enters something in the txtSource field, then he submits the form, the database returns a string that is then shown in the txtProductName field. Well, that's the idea. But it doesn't work. txtProductName is always empty. I don't know why because $product is not empty?? I've also tried using setDefaults but it doesn't work either. If you have any idea...
When you add an element to the form, its value is overwritten by the value contained in the form (e.g. submitted value or set via setDefaults()). Therefore it is useless to try to set the value the way you do, you should set the value *after* you add the element. setDefaults() "doesn't work" for the other reason: default values are overwritten by submitted and you have an empty string as a submitted value of txtProductName. To sum it up, you have two options: 1) set the value of the element via setValue() after you add that element to the form; 2) use setConstants(), constants override submitted values.

« previous php.pear.general (#21142) next »