[Petal] How do I use selected/checked ?

Chris Croome chris at webarchitects.co.uk
Wed Aug 31 08:55:24 BST 2005


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>

Chris

-- 
Chris Croome                               <chris at webarchitects.co.uk>
web design                             http://www.webarchitects.co.uk/ 
web content management                               http://mkdoc.com/   


More information about the Petal mailing list