[Petal] How do I use selected/checked ?

wsmith wsmith at hbslabs.com
Wed Aug 31 16:30:19 BST 2005


If you get the decode: modifier from Petal::Utils, you can keep it in
one:

<input type="checkbox" petal:attributes="checked decode: myinput/checked
1 1" />

This reads:
If the value of myinput/checked is exactly 1, set the checked attribute.
Otherwise, do not set it.

On Wed, 2005-08-31 at 09:31 -0400, jonathan vanasco wrote:
> OK. that makes perfect sense.
> 
> thats in the docs, but unexplained, so i didn't know what to look for  
> in that example.
> 
> 
> 
> On Aug 31, 2005, at 3:55 AM, Chris Croome wrote:
> 
> > Hi
> >
> > On Wed 31-Aug-2005 at 12:56:59AM -0400, Jonathan Vanasco wrote:
> >
> >> I'm a moron and I can't figure this out.
> >>
> >> I know that to be xhtml compliant it must be
> >>     selected="selected"
> >>     checked="checked"
> >>
> >> that's fine.
> >>
> >> what I can't figure out is how to structure that in petal.
> >>
> >
> > The way I do it is by repeating the option element, at first this
> > seems a bit off but it's OK since it actually makes the template
> > more like the actual page when it's being developed and tested, for
> > example this is how the select list for the language of a document
> > is generated for MKDoc:
> >
> >   <select
> >     name="lang"
> >     id="lang"
> >     class="select"
> >     title="Select the language."
> >
> >>
> >>
> >     <option
> >       value="en"
> >       title="en"
> >       selected="selected"
> >       petal:condition="true: self/selected_lang"
> >       petal:attributes="value self/selected_lang/value;
> >                         title self/selected_lang/value;"
> >       petal:content="self/selected_lang/label"
> >
> >> English</option>
> >>
> >     <option
> >       value="i-klingon"
> >       title="i-klingon"
> >       petal:repeat="lang self/unselected_langs"
> >       petal:attributes="value lang/value;
> >                         title lang/value;"
> >       petal:content="lang/label"
> >
> >> Klingon</option>
> >>
> >   </select>
> 



More information about the Petal mailing list