Re: option selected

William McKee <[email protected]>
Newsgroups gmane.comp.lang.perl.modules.petal
Message-ID <[email protected]>
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
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.