RE: [PEAR] Question: QuickForm IT_Static & hierselect
| From: | Michael Mussulis | Date: | Fri, 31 Oct 2008 10:39:21 +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-29391@lists.php.net to get a copy of this message | ||
Alexey,
Sorry to be a pain, but I am quite confused as to how I am supposed to get
this working. I have done as follows:
$form->registerElementType("myhs", "myhierselect.php",
"MyHierselect");
$hs =& $form->addElement("myhs", 'makemodel',
'Make/Model:',
array('class' => 'element'), ' ');
$hs->setOptions($opts);
$js = $hs->toHtml();
die($js);
$js contains both selects, but there's a problem with the group name as
shown below:
<select name="[0]" onchange="_hs_swapOptions(this.form, '',
0);">
The normal hierselect outputs:
<select class="element" name="makemodel[0]"
onchange="_hs_swapOptions(this.form, 'makemodel', 0);">
Why am I losing the group name? What should I do to correct it?
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'), ' ');
>>>>
>>>> $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.
>>>
>>
>>
>