On Nov 26, 2007 12:17 AM, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
>
> I'm trying to implement a checkbox using TG 1.0.4b2 with Genshi.
>
> Here's the relevant line in my template:
>
> <input type="checkbox" name="red" checked="tg.checker()" />RED<br />
>
> No matter what I put inside the parentheses for tg.checker, the box
> always ends up checked.  Even when (as shown above) I put in
> nothing...which I assume should definitely be false, right?
>
> Here's the relevant source fed to my web browser:
> <input type="checkbox" name="red" checked>RED<br>
>
> What am I doing wrong?

Your checkbox will always be checked because your input's 'checked'
attribute isn't going to be evaluated properly in python and Genshi
will output (X)HTML which will mean your input will look like:

<input type="checkbox" name="read" checked/>

To make it actually evaluate your tg.checker() part, just use py:attrs
instead of repeating the element:

<input type="checkbox" name="red"
py:attrs="{'checked':tg.checker(some_expression)}"/>

This works in exactly the same way as tg.selected() when using option
tags within selects.


-- 
Lee McFadden

blog: http://www.splee.co.uk
work: http://fireflisystems.com
skype: fireflisystems

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"TurboGears" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/turbogears?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to