Re: How do I use selected/checked ?

Olaf Buwen <[email protected]>
Newsgroups gmane.comp.lang.perl.modules.petal
Message-ID <[email protected]>
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
Olaf
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.