Re: Re: QF2 - setTemplateClass for radios?

From: Date: Mon, 26 Mar 2012 18:56:50 +0000
Subject: Re: Re: QF2 - setTemplateClass for radios?
References: 1 2 3 4 5  Groups: php.pear.general 
Request: Send a blank email to pear-general+get-31478@lists.php.net to get a copy of this message
That's perfect, that's exactly what I was looking for. Sorry the start/finish bit was just me trying to show that I was looking for answers ... On Mon, Mar 26, 2012 at 11:46 AM, Alexey Borzov <borz_off@cs.msu.su> wrote: > Hi Mark, > > > On 26.03.2012 22:22, Mark Steudel wrote: >> >> I was wondering if you could expand upon how to set the template for a >> group of elements? > > > Well, there are two templates: an outer template for a group and an inner > template for an element inside a group. > > The former defaults to (line breaks and indents added for clarity): > > <div class="row"> >  <p class="label"> >  <qf:required><span class="required">*</span></qf:required> >  <qf:label><label>{label}</label></qf:label> >  </p> >  <div class="element group<qf:error> error</qf:error>" > id="{id}"> >  <qf:error><span class="error">{error}<br > /></span></qf:error> >  {content} >  </div> > </div> > > and the latter defaults to {element} (i.e., no template). > > {content} in group's template will be replaced by elements' HTML (possibly > wrapped into their templates) with separators (set via setSeparator()) in > between. > > (Outer) template for a group can be set by setTemplateForId() and > setTemplateForClass(). (Inner) template for a grouped element can be set by > setTemplateForId(), setElementTemplateForGroupId() and > setElementTemplateForGroupClass(). > > > >> I was looking at startGroup or finishGroup but that didn't really seem >> like what I was looking for. > > > If you specify what you were looking for and show how you were trying to > achieve your goals, it will be a lot easier to help. > > > >> On Wed, Mar 21, 2012 at 12:42 PM, Alexey Borzov<borz_off@cs.msu.su> >>  wrote: >>> >>> Hi Mark, >>> >>> >>> On 21.03.2012 23:29, Mark Steudel wrote: >>>> >>>> >>>> Ok so I think part of the problem is that the radios are in a group, >>>> but I'm still having problems setting the template: >>> >>> >>> >>> For reference, the algorithm Default Renderer uses to search for >>> templates >>> *is* documented: >>> >>> http://pear.php.net/manual/en/package.html.html-quickform2.renderers.php >>> >>> >>>> Here's my group code: >>>> >>>>  $boxGroup = $form->addElement( 'group', 'gender' >>>> )->setLabel( 'Choose >>>> gender' ); >>> >>> >>> >>> I'd suggest not giving a name to this group but giving an explicit id: >>> >>> $boxGroup = $form->addElement('group')->setLabel('Choose >>> gender')->setId('gender'); >>> >>> >>>>         $boxGroup->addElement( 'radio', 'gender', array( >>>> 'value' => >>>> 'male' ) )->setContent( 'Male' ); >>>>         $boxGroup->addElement( 'radio', 'gender', array( >>>> 'value' => >>>> 'female' ) )->setContent( 'Female' ); >>>>         $boxGroup->addRule( 'required', 'Please choose >>>> gender' ); >>>> >>>> Here's my code to try and set template: >>>> >>>> $renderer->setElementTemplateForGroupClass( 'gender', >>>> 'HTML_QuickForm2_Element_InputRadio', $defaultTemplate ); >>> >>> >>> >>> And here you should use setElementTemplateForGroupId(), since you want to >>> set a template for radios in a specific group rather than in all groups: >>> >>> $renderer->setElementTemplateForGroupId('gender', >>> 'HTML_QuickForm2_Element_InputRadio', $defaultTemplate); >>> >>> >>> Yeah, I know that groups need more documentation. It's on my todo list. >>> >>> >>> >>>> On Wed, Mar 21, 2012 at 11:51 AM, Mark Steudel<msteudel@gmail.com> >>>>  wrote: >>>>> >>>>> >>>>> So this should be silly easy but the two options I tried didn't work, >>>>> I'm trying to set the template for radio buttons: >>>>> >>>>> $renderer->setTemplateForClass( >>>>> 'HTML_QuickForm2_Element_InputRadio', >>>>> $defaultTemplate ); >>>>> >>>>> And I can't figure out what value I should use, I tried >>>>> HTML_QuickForm2_Element_InputRadio and HTML_QuickForm2_Element_Radio. >>>>> What do I use? >>>>> >>>>> Thanks, Mark >>>>> -- >>>>> ----------------------------------------- >>>>> Mark Steudel >>>>> P: 425.298.7244 >>>>> F: 206.260.3021 >>>>> msteudel@gmail.com >>>>> >>>>> . : Work : . >>>>> http://www.mindfulinteractive.com >>>>> >>>>> . : Play : . >>>>> http://www.steudel.org/blog >>>>> >>>>> . : LinkedIn : . >>>>> http://www.linkedin.com/in/steudel >>>> >>>> >>>> >>>> >>>> >>> >>> >>> -- >>> PEAR General Mailing List (http://pear.php.net/) >>> To unsubscribe, visit: http://www.php.net/unsub.php >>> >> >> >> > -- ----------------------------------------- Mark Steudel P: 425.298.7244 F: 206.260.3021 msteudel@gmail.com . : Work : . http://www.mindfulinteractive.com . : Play : . http://www.steudel.org/blog . : LinkedIn : . http://www.linkedin.com/in/steudel

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