Author: jmorliaguet Date: Thu Feb 9 14:59:16 2006 New Revision: 2332 Modified: cpsskins/branches/jmo-perspectives/ui/framework/tests/zope3/functional/forms/browser.py cpsskins/branches/jmo-perspectives/ui/framework/tests/zope3/functional/forms/cpsskins_form_validation.pt Log:
- added support readonly field properties - began adding support for Choice fields Modified: cpsskins/branches/jmo-perspectives/ui/framework/tests/zope3/functional/forms/browser.py ============================================================================== --- cpsskins/branches/jmo-perspectives/ui/framework/tests/zope3/functional/forms/browser.py (original) +++ cpsskins/branches/jmo-perspectives/ui/framework/tests/zope3/functional/forms/browser.py Thu Feb 9 14:59:16 2006 @@ -6,7 +6,7 @@ from zope.app.cache.ram import RAMCache from zope.interface import Interface -from zope.schema import Text +from zope.schema import Text, Choice, Int from zope.schema.fieldproperty import FieldProperty from cpsskins import minjson as json @@ -38,7 +38,19 @@ required=False, ) -form_layout = ['firstname', 'lastname', 'email'] + gender = Choice( + title=u'Gender', + values=(u'Male', u'Female') + ) + + id = Int( + title=u'Identifier', + default=100, + readonly=True, + ) + +# TODO: move this to the view definition +form_layout = ['firstname', 'lastname', 'email', 'gender', 'id'] class Views(BrowserView): @@ -60,6 +72,7 @@ 'label': field_def.title, 'hint': field_def.description, 'value': field_def.default, + 'disabled': field_def.readonly, 'status': u'', }) return {'fields': fields} @@ -91,7 +104,7 @@ if constraint is not None: m = constraint(value) if not m: - field['status'] = u"Incorrect value" + field['status'] = u"Incorrect value" valid = False field['value'] = value Modified: cpsskins/branches/jmo-perspectives/ui/framework/tests/zope3/functional/forms/cpsskins_form_validation.pt ============================================================================== --- cpsskins/branches/jmo-perspectives/ui/framework/tests/zope3/functional/forms/cpsskins_form_validation.pt (original) +++ cpsskins/branches/jmo-perspectives/ui/framework/tests/zope3/functional/forms/cpsskins_form_validation.pt Thu Feb 9 14:59:16 2006 @@ -40,6 +40,11 @@ background-color: #fff; } + input.disabled { + border-style: none; + color: black; + } + input:focus { background-color: #ffc; } @@ -97,28 +102,42 @@ tag: "label", text: field.label }); - var hint = Canvas.createNode({ - tag: "span", - classes: "hint", - text: '(' + field.hint + ')' - }); + p.appendChild(label); + + + var input_options = { + "tag": "input", + "attributes": { + "name": field.name, + "type": "text", + "value": field.value, + } + } + + if (field.disabled == true) { + input_options["attributes"]["disabled"] = "disabled"; + input_options["classes"] = "disabled"; + } + + var input = Canvas.createNode(input_options); + p.appendChild(input); + + if (field.hint) { + var hint = Canvas.createNode({ + tag: "span", + classes: "hint", + text: '(' + field.hint + ')' + }); + p.appendChild(hint); + } + var status = Canvas.createNode({ tag: "span", classes: "status", text: field.status }); - var input = Canvas.createNode({ - tag: "input", - attributes: { - "name": field.name, - "type": "text", - "value": field.value - } - }); - p.appendChild(label); - p.appendChild(input); - p.appendChild(hint); p.appendChild(status); + return p; } -- http://lists.nuxeo.com/mailman/listinfo/z3lab-checkins