Page 1 of 1

PHPTAL

Posted: Tue Dec 19, 2006 3:00 pm
by shiznatix
So yes I am using PHPTAL for templating and it is working out quite well for me.

The problem I have is trying to have a select option pre selected when populating the options dynamically. Like this:

Code: Select all

<select name="fkStateId">
    <option value=""></option>
    <option tal:repeat="state States" tal:attributes="value state/Id" tal:content="state/State">
    </option>
</select>
How would I go about making a conditional attribute? I have tried things like this:

Code: Select all

<select name="fkStateId">
    <option value=""></option>
    <option tal:repeat="state States" tal:attributes="value state/Id; selected php: state/Id == SelectedState ? 'selected' : ''" tal:content="state/State">
    </option>
</select>
but that gives me the error that state/Id does not exist or whatever. I searched google and the mailing list stuff to no real solution. Anyone know how this could be accomplished?