[Petal] option selected
William McKee
william at knowmad.com
Wed Dec 22 15:38:33 GMT 2004
Hi Simon,
> <option
> tal:repeat="cat cat_list"
> tal:attributes="selected if: eq: $cat/id $item/cat/id then: string:true
> else: nothing"
> value="$cat/id"
> petal:content="cat/name"
> >Category</option>
>
> I think this is a tidy solution to this problem, and it means I can keep it
> all in the template
If you are looking for tidy solutions, I'd suggest trying the decode
modifier that is part of Petal::Utils v0.06. This would make your code
look something like the following (untested!):
<option
tal:repeat="cat cat_list"
tal:attributes="selected decode:$cat/id $item/cat/id 'true'"
value="$cat/id"
petal:content="cat/name">Category</option>
> Is there anywhere this information is posted - wiki etc..? This would be
> useful. Any pointers to good tutroials, there must be so much more I could
> do, but don't know how...?
Unfortunately not. It's come up a couple times on the list. In the
meantime, I suggest browsing the mailing list archives. Besides some
interesting conversations (some of them a bit esoteric), you should find
some code samples. I have a test file that contains many examples which
I can send if you don't find it in the archives. Let me know.
Cheers,
William
--
Knowmad Services Inc.
http://www.knowmad.com
More information about the Petal
mailing list