Re: Help with extending HTML_QuickForm_select

From: Date: Sat, 05 Feb 2005 01:08:06 +0000
Subject: Re: Help with extending HTML_QuickForm_select
References: 1  Groups: php.pear.dev 
Request: Send a blank email to pear-dev+get-35953@lists.php.net to get a copy of this message
On Fri, 04 Feb 2005 16:52:54 -0800, Jamie Alessio <Jamie.Alessio@ucop.edu> wrote: > I'm working on implementing an HTML_QuickForm element for an "advanced > multiple select". Basically, instead of having to ctrl+click items in a > multselect it displays two multselect boxes side by side and allows you > to move items between the two boxes (example at > http://jalessio.com/pear/advmultselect.php). > > I'm using javascript to handle moving the data between the multselect > boxes. Presently, the only way to get the selected items into the > $_REQUEST array upon form post is to add a javascript function call to > the <form> tag so it looks something like this: > > <form action="test.php" method="post" > onsubmit="javascript:myJsFunction(blah);"> > > The javascript is not a problem, but this requires that I add the > "onsubmit" attribute to the <FORM> tag and I'm struggling with how to > properly do this within the structure of HTML_QuickForm. As far as I can > tell the only chance that a class that extends HTML_QuickForm has to > modify the attributes of the the <FORM> tag is via the $caller variable > in the onQuickFormEvent($event, $arg, &$caller) method in my inherited > class. The only way I have gotten this to work so far is by catching > when onQuickFormEvent() is called with an 'addElement' event and doing > something like this: > > $caller->updateAttributes(array( > 'onsubmit' => "javascript: myJsFunction(blah)")); > > Is this a *correct* way to do this? Can I reliably count on being able > to set this during the 'addElement' event? Any thoughts on a better way > to have a subclass of HTML_QuickForm modify the attributes of the <FORM> > tag that the element is going to be a member of? This sounds like the "correct: way of doing this, but.... > > You can view an example of how this is currently working at > http://jalessio.com/pear/advmultselect.php and please let me > know if you > have any problems with this in your browser of choice. > I would suggest you instead have another (hidden) box with the selected values in it *and* selected. Or create a hidden element with the values for each selected value. This way you don't have to rely on an onsubmit. -- Justin Patrin

« previous php.pear.dev (#35953) next »