2008/6/29, Levi Stanley <[EMAIL PROTECTED]>:
> Was wondering if there was a better way to deal with radio buttons &
>  selection box in phptal.
>  One way, is make an array, and pass it the choices to the template.
>  Or you can do it like the method below, however I was wondering if there
>  is a better way than doing it like this?

First of all you are not allowed to put "span" inside "select"
element. For such things like grouping, please use tal:block.
<tal:block tal:condition="">
This is element that will be removed before generating output (but of
course respected by parser).

I don't have any really clean solution for selects. I use something like this:
<select name="layout">
    <option value="0" tal:attributes="selected no">no</option>
    <option value="1" tal:attributes="selected maybe">maybe</option>
    <option value="3" tal:attributes="selected yes">yes</option>

$template->no = false;
$template->maybe = true;
$template->yes = false;

PHPTAL converts this to nice XHTML (selected="selected").

Rafał Miłecki
PHPTAL mailing list

Reply via email to