Re: QF subforms: separate form template for the subform?

From: Date: Thu, 08 Sep 2005 17:11:13 +0000
Subject: Re: QF subforms: separate form template for the subform?
References: 1  Groups: php.pear.general 
Request: Send a blank email to pear-general+get-20870@lists.php.net to get a copy of this message
On 9/8/05, Ignatius Reilly <ignatius.reilly@free.fr> wrote: > I am experimenting with the *splendid* QF "subform" element. > So far so good. > I'm glad you like it. I was pleased with how well it worked. It's also just a delightful little hack. :-) > Now I want to assign a distinct form template to the subform, distinct > from the main form's template, that is. > I really mean here the form template, not the element template for the > subform element (this can be set as usual, which is great) > > Has anybody an idea whether this can be done? > At first sight it can not: it seems to me that there can be only one > renderer instance, which can be assigned only one form template. > Hopefully I have overlooked something... > > I am using HTML_QuickForm_Renderer_Default() > Well, you've run into the limitation I ended up building into the SubForm element. For it to work "correctly" I had to hard-code in, as it were, the use of the default template. I assume what you want to change is the <div> and <table>? The <form> HTML is removed on line 136 (of course it is, nested forms in HTML make no sense). You should be able to do this by altering the default renderer with the template you want for the SubForm and then applying a renderer object to the main form instead of letting it use the default. Something like this: //create form(s) here $default =& HTML_QuickForm::defaultRenderer(); $renderer = clone(HTML_QuickForm::defaultRenderer()); $default->setFormTemplate('form template for SubForms'); $renderer->setFormTemplate('form template for main form'); //you could also set any other templates you wish here //$form is the main form $form->accept($renderer); echo $renderer->toHtml(); Of course, this method only works if you want the same template applied to all SubForms in your form. But, again, this is a limitation due to how QF is laid out. This *could* be fixed by allowing a renderer to be set for subforms, but since it inly supports the default renderer (currently) this could lead to confusion. -- Justin Patrin

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