RE: [PEAR] Quickform SetDefaults
| From: | Mike Carter | Date: | Tue, 06 Jan 2004 12:36:22 +0000 |
| Subject: | RE: [PEAR] Quickform SetDefaults | ||
| References: | 1 | Groups: | php.pear.general |
| Request: | Send a blank email to pear-general+get-9995@lists.php.net to get a copy of this message | ||
Hi,
Just a quick side note, but would it not be simpler to use the line below to
create a new hidden element...
$this->addElement('hidden', 'action');
Also, the second time a form is displayed; you cannot set values because the
ones in the posted take priority. You need to use the setdefaults() from my
experience - these override anything in the forms posted values
Regards,
Mike c
> -----Original Message-----
> From: Barry Steele [mailto:barry@hpfm.biz]
>
> On Tue, 2004-01-06 at 01:43, Alexey Borzov wrote:
> > Hi!
> >
> > Barry Steele wrote:
> > > As you see I set the data after the fields are set.
> Essentially what I
> > > need to do is to try to clear any data that was held in
> the container -
> > > I thought "$this->controller->container(true);" - would do it.
> >
> > It usually does for me... I have a feeling that it is not
> really called.
> >
> > When is the method you posted (setValues()) called?
>
> Hi,
> I think I've regressed to presimian thought processes.
>
> My process goes like :-
>
> function _buildform
> {
> $this->_formBuilt = true;
> //create and add lots of elements
> $this->addElement('submit',$this->getButtonName('next'), 'Add
> Incident
> Data');
> // add rules
> if (!$this->elementExists('action'))
> {
> $action = new HTML_QuickForm_hidden('action');
> $this->addElement($action);
> }
> else
> {
> $action = $this->getElement('action');
> }
> $action->setValue($_REQUEST['action']);
> if ($_REQUEST['action'] == 'edit')
> {
> echo "OK now we edit ".$_REQUEST['IncidentID']."<br>";
> $incident = new incident();
> $incident->find($_REQUEST['IncidentID']);
> if (!$incident)
> die( "Couldn't find Incident
> ".$_REQUEST['IncidentID']."<br>"); //
> replace with true error handling
> $id = new HTML_QuickForm_hidden('IncidentID');
> $this->addElement($id);
> $this->setValues($incident);
> }
> else
> {
> echo "we don't have an edit - set values to null<br>";
> $this->setValues(null);
> }
> Var_Dump::display($_REQUEST);
> Var_Dump::display($_SESSION);
> }
>
> The form has two Quickform_Pages and the setValues and I get
> the problem
> with setting values only after the first submit but the output from -
>
> Var_Dump::display($_REQUEST);
> Var_Dump::display($_SESSION);
>
> is --
>
> Building Data Entry form
> we don't have an edit - set values to null
> Setting Values
> action String[3] (new)
> PHPSESSID String[32] (a4ebccf0de7a3bcab5cd0b91325748fe)
> valid_username String[11] (NSW_63_slsc)
> valid_password String[0] ()
> valid_user_id String[2] (50)
> _Incident Mgt_container Array(4)
>
> + defaults Empty array ()
> | constants Empty array ()
> | values Array(2)
> |
> | + incident Empty array ()
> | + resus Empty array ()
> |
> + valid Array(2)
> |
> | + incident Null (Null)
> | + resus Null (Null)
> |
> I'm assuming that I'm doing this all backwards so I'd
> appreciate you're thoughts.
>
>
>
>
> Barry Steele
> hpfm solutions pty ltd
> mob: 0413947980
> fax: 0299817727
> mailto:: barry@hpfm.biz
>
> --
> PEAR General Mailing List (http://pear.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
________________________________________________________________________
This email has been scanned for all viruses by the MessageLabs Email
Security System. For more information on a proactive email security
service working around the clock, around the globe, visit
http://www.messagelabs.com
________________________________________________________________________