Le samedi 26 avril 2008 à 22:04 +0200, Krzysztof Sikorski a écrit :

> >  If ($agreement) {
> >
> >  <input type="checkbox" name="agreement" value="1" checked="checked" />
> >
> >  } else {
> >
> >  <input type="checkbox" name="agreement" value="1" />
> >
> >  }
> 

Hi Krzysztof,

> Exact conversion of your code would be:
> <input tal:condition="agreement" type="checkbox" name="agreement"
> value="1" checked="checked" />
> <inout tal:condition="not:agreement" type="checkbox" name="agreement"
> value="1" />

Humm this is not really good for me because this will put 2 checkbox if
we look the template
in a browser. 


> 
> You could also try code like this, but if condition evaluates to false
> it will produce an empty argument instead of removing it completely -
> which is not exactly what you asked for:
> <input type="checkbox" name="agreement" value="1"
> tal:attributes="checked php: agreement ? checked : null" />

Yes but the problem is somes browser will see : checked="" and they will
check the box .. 

But I have may be found a solution, not yet tried :
tal:attribute="class php: agreement ? "checked" : false"
But it's a little bit annoying to do that each time.
I'll try to create a custom modifier like that :
tal:attribute="checked checkbox: agreement"

Thanks 

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

Reply via email to