I have the feeling that this should be possible, and maybe trivial,
but I don't know how to solve it.


I have an object ($person), who lives in a state ($person->state).
I also have a list of states ($states). Both are assigned to phptal.

$phptal->person = $person;
$phptal->states = $states;


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>


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

Reply via email to