1 Sep 10:48
Re: How do I use selected/checked ?
This template:
<select>
<option
petal:repeat="entry options"
petal:attributes="value entry/lang; selected entry/selected"
petal:content="entry/title"/>
</select>
with this code:
...
print $template->process(
options => [
{lang => "foo", title => "Foobar"},
{lang => "bar", title => "Barbar", selected => 'selected'},
{lang => "baz", title => "Bazbar"},
]
);
gives this output:
<select>
<option value="foo" >Foobar</option>
<option value="bar" selected="selected">Barbar</option>
<option value="baz" >Bazbar</option>
</select>
It is not in the docs, but AFAIK it is part of the TAL spec
that an attribute is not set when the appropriate entry is missing.
I hope this helps
(Continue reading)

RSS Feed