On 14-10-2009 at 17:49:44 GRolf <ger...@pictureparking.com> wrote:

In my PHPTAl template I have

<select name="state">
<option tal:repeat="state states" value="${state}">${state}</option>
</select>

I'd like PHPtal to put the state of $person to selected. I know how to
achieve it when I loop through the states array in PHP first, add an
"active" flag to the one state that is active and use tal:attributes
then, but would it be possible to achieve it without looping through
all states in php?

something like ...

<option tal:repeat="state states" tal:attributes="selected person/state eq state" value="${state}">${state}</option>

Unfortunately that's one case where pure TALES isn't enough and you have to use php: modifier.


tal:attributes="selected php:person['state'] == state"

(or person.state or person.state() depending whether that's array/object property/method)

--
regards, Kornel

_______________________________________________
PHPTAL mailing list
PHPTAL@lists.motion-twin.com
http://lists.motion-twin.com/mailman/listinfo/phptal

Reply via email to