Hi, Can anyone suggest how to implement a check box in ZPT When I create an edit form from a database I want a check box that is either checked or not depending on the value in the database I am aware of tal:attributes but need to know how to bend it to create HTML like <input checked type="checkbox" name="UKSC" value="checkbox" > ^^^^^^^ TIA David Kyte
David Kyte wrote:
When I create an edit form from a database I want a check box that is either checked or not depending on the value in the database
It's the same as selected see: http://www.zope.org/Members/peterbe/DTML2ZPT/#example14 -- Luca Olivetti Wetron Automatización S.A. http://www.wetron.es/ Tel. +34 93 5883004 Fax +34 93 5883007
On Fri, May 31, 2002 at 10:30:23AM +0100, David Kyte wrote:
Hi,
Can anyone suggest how to implement a check box in ZPT
When I create an edit form from a database I want a check box that is either checked or not depending on the value in the database
I am aware of tal:attributes but need to know how to bend it to create HTML like
<input checked type="checkbox" name="UKSC" value="checkbox" >
Like this: <input type="checkbox" name="UKSC" value="checkbox" tal:attributes="checked some_boolean_expression"> Note that the checked attribute is optional. This also works <input type="checkbox" name="UKSC" value="checkbox" checked tal:attributes="checked some_boolean_expression"> And so does this: <input type="checkbox" name="UKSC" value="checkbox" checked="1" tal:attributes="checked some_boolean_expression"> I really do not like the last form, though. In fact, <input type="checkbox" name="UKSC" value="checkbox" checked="Holy, sweet babaloo" tal:attributes="checked some_boolean_expression"> works. In all cases, the actual output will be something like: <input type="checkbox" name="UKSC" value="checkbox" checked="checked"> for a checked item, and <input type="checkbox" name="UKSC" value="checkbox"> for an unchecked item. Jim Penny
TIA
David Kyte
_______________________________________________ Zope maillist - Zope@zope.org http://lists.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://lists.zope.org/mailman/listinfo/zope-announce http://lists.zope.org/mailman/listinfo/zope-dev )
I have done it like this: <input checked type="checkbox" name="UKSC" value="checkbox" tal:condition="test_value"> <input type="checkbox" name="UKSC" value="checkbox" tal:condition="not:test_value"> There probably is a better way. One of the problem is that it can get messy when you have a lot of fields. On Fri, 2002-05-31 at 04:30, David Kyte wrote:
Hi,
Can anyone suggest how to implement a check box in ZPT
When I create an edit form from a database I want a check box that is either checked or not depending on the value in the database
I am aware of tal:attributes but need to know how to bend it to create HTML like
<input checked type="checkbox" name="UKSC" value="checkbox" > ^^^^^^^
TIA
David Kyte
_______________________________________________ Zope maillist - Zope@zope.org http://lists.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://lists.zope.org/mailman/listinfo/zope-announce http://lists.zope.org/mailman/listinfo/zope-dev )
participants (4)
-
David Kyte -
Eugene von Niederhausern -
Jim Penny -
Luca Olivetti