RE: [PEAR] Question: QuickForm IT_Static & hierselect

From: Date: Wed, 29 Oct 2008 23:04:55 +0000
Subject: RE: [PEAR] Question: QuickForm IT_Static & hierselect
References: 1 2 3 4 5 6 7 8  Groups: php.pear.general 
Request: Send a blank email to pear-general+get-29381@lists.php.net to get a copy of this message
Hi, When I meant Ajax, I meant completely getting replacing hierselect like this: $form->addElement('select', 'sel1', 'blah:', $opts1, array('id'=>'sel1')); $form->addElement('select', 'sel2', 'blah:', null); And then use jQuery for example to bind an Ajax call on 'sel1' like: $('#sel1').chainSelect(); (chainSelect is a pluging) I've already made this work using jQuery + Ajax. I was hoping to get native Quickform method working as well (hierselect + IT_Static) so I can have the choice of the two methods, each having pro-cons. It would be great if someone could come up with a full example of getting 'hierselect' to work with IT_Static template, to render each select individually. Thanks, Michael. -----Original Message----- From: Alexey Borzov [mailto:borz_off@cs.msu.su] Sent: Thursday, October 30, 2008 12:28 AM To: Michael Mussulis Cc: pear-general@lists.php.net Subject: Re: [PEAR] Question: QuickForm IT_Static & hierselect Hi, Michael Mussulis wrote: > Ok, so basically you are talking about overriding two methods at least to > get it work. Basically you'll only have to override accept(). > Perhaps it would be easier to just replace the hierselect with > 2 individual selects, the 2nd controlled by an Ajax script, what do you > think? It may be easier indeed. Also hierselect doesn't do AJAX, so if you want to send requests for second select's data that's your only option. > -----Original Message----- > From: Alexey Borzov [mailto:borz_off@cs.msu.su] > Sent: Wednesday, October 29, 2008 11:55 PM > To: Michael Mussulis > Cc: pear-general@lists.php.net > Subject: Re: [PEAR] Question: QuickForm IT_Static & hierselect > > Hi. > > Michael Mussulis wrote: >> I am sorry, but I don't understand what u mean by hacking hierselect + >> accept() - do you have an example by any chance? I don't think playing > with >> the separators will accomplish my needs which are something like: >> >> <tr><td>{label1}</td><td><select 1></td></tr> >> <tr><td>{label2}</td><td><select 2></td></tr> > > Well, that leaves us with changing the accept() method. I meant doing > something > along the lines of > > class MyHierselect extends HTML_QuickForm_hierselect > { > function accept(&$renderer, $required = false, $error = null) > { > HTML_QuickForm_group::accept($renderer, $required, $error); > } > } > > although looking now at the source, it won't quite work. You'll need also to > > output javascript that is now generated in toHTML() method, this will > require a > new accept() method based on group's accept() and hierselect's toHtml(). > > > >> -----Original Message----- >> From: Alexey Borzov [mailto:borz_off@cs.msu.su] >> Sent: Wednesday, October 29, 2008 11:22 PM >> To: Michael Mussulis >> Cc: 'pear-general@lists.php.net' >> Subject: Re: [PEAR] Question: QuickForm IT_Static & hierselect >> >> Hi Michael, >> >> Please reply to the list, other people may also be interested in your >> problem. >> >> Michael Mussulis wrote: >>> That' fine, it works but it's not what I am looking for. >>> I want to render each of the selects separately, and that's what I don't >>> know how to achieve (if possible in the first place). >> You can either hack hierselect to use the same accept() method as group or >> play >> with separators (that, of course, will work if you aren't trying to put >> selects >> too far away from each other). >> >> >>> -----Original Message----- >>> From: Alexey Borzov [mailto:borz_off@cs.msu.su] >>> Sent: Wednesday, October 29, 2008 3:08 PM >>> To: Michael Mussulis >>> Cc: pear-general@lists.php.net >>> Subject: Re: [PEAR] Question: QuickForm IT_Static & hierselect >>> >>> Hi, >>> >>> Michael Mussulis wrote: >>>> I was just wondering if you could possibly help me figure out how I can >>>> render the selects from a 'hierselect' element using IT_Static template? >>>> Everything I tried just does not work. >>>> >>>> My element is: >>>> >>>> $hs =& $form->addElement('hierselect', 'makemodel', >>>> 'Make/Model:', >>>> array('class' => 'element'), '&nbsp;'); >>>> >>>> $hs->setOptions($opts); >>>> >>>> I output the form as follows: >>>> >>>> $tpl =& new HTML_Template_ITX(); >>>> >>>> $tpl->loadTemplateFile('adauga.html'); >>>> >>>> $renderer =& new HTML_QuickForm_Renderer_ITStatic($tpl); >>>> >>>> $form->accept($renderer); >>>> >>>> $tpl->show(); >>>> >>>> In my html template, I tried: >>>> >>>> <tr><td >>>> class="label">{frmad_makemodel_0_label}</td><td >>>> class="element">{frmad_makemodel_0_html}</td></tr> >>>> >>>> But it doesn't work. Although the documentation says the element is >>>> considered a group, IT_Static treats it as an element. >>> Yes, exactly, 'date' and 'hierselect' elements are treated like >>> "scalar" >>> elements for the purposes of rendering. You probably should put >>> >>> <tr><td class="label">{frmad_makemodel_label}</td><td >>> class="element">{frmad_makemodel_html}</td></tr> >>> >>> into your template. >>> >> >> >

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