[Checkins] SVN: z3c.form/trunk/ - Added all available HTML
attributes.
Stephan Richter
srichter at cosmos.phy.tufts.edu
Tue Jul 3 01:30:37 EDT 2007
Log message for revision 77324:
- Added all available HTML attributes.
Changed:
U z3c.form/trunk/CHANGES.txt
U z3c.form/trunk/src/z3c/form/browser/README.txt
U z3c.form/trunk/src/z3c/form/browser/checkbox.py
U z3c.form/trunk/src/z3c/form/browser/checkbox.txt
U z3c.form/trunk/src/z3c/form/browser/checkbox_input.pt
U z3c.form/trunk/src/z3c/form/browser/file.py
U z3c.form/trunk/src/z3c/form/browser/file.txt
U z3c.form/trunk/src/z3c/form/browser/file_input.pt
A z3c.form/trunk/src/z3c/form/browser/interfaces.py
U z3c.form/trunk/src/z3c/form/browser/orderedselect.py
U z3c.form/trunk/src/z3c/form/browser/orderedselect.txt
U z3c.form/trunk/src/z3c/form/browser/orderedselect_input.pt
U z3c.form/trunk/src/z3c/form/browser/password.txt
U z3c.form/trunk/src/z3c/form/browser/password_input.pt
U z3c.form/trunk/src/z3c/form/browser/radio.py
U z3c.form/trunk/src/z3c/form/browser/radio.txt
U z3c.form/trunk/src/z3c/form/browser/radio_input.pt
U z3c.form/trunk/src/z3c/form/browser/select.py
U z3c.form/trunk/src/z3c/form/browser/select.txt
U z3c.form/trunk/src/z3c/form/browser/select_input.pt
U z3c.form/trunk/src/z3c/form/browser/submit.py
U z3c.form/trunk/src/z3c/form/browser/submit.txt
U z3c.form/trunk/src/z3c/form/browser/submit_input.pt
U z3c.form/trunk/src/z3c/form/browser/tests.py
U z3c.form/trunk/src/z3c/form/browser/text.py
U z3c.form/trunk/src/z3c/form/browser/text.txt
U z3c.form/trunk/src/z3c/form/browser/text_input.pt
U z3c.form/trunk/src/z3c/form/browser/textarea.py
A z3c.form/trunk/src/z3c/form/browser/textarea.txt
U z3c.form/trunk/src/z3c/form/browser/textarea_input.pt
A z3c.form/trunk/src/z3c/form/browser/widget.py
U z3c.form/trunk/src/z3c/form/interfaces.py
U z3c.form/trunk/src/z3c/form/widget.py
U z3c.form/trunk/src/z3c/form/widget.txt
U z3c.form/trunk/src/z3c/form/zcml.txt
-=-
Modified: z3c.form/trunk/CHANGES.txt
===================================================================
--- z3c.form/trunk/CHANGES.txt 2007-07-03 02:36:45 UTC (rev 77323)
+++ z3c.form/trunk/CHANGES.txt 2007-07-03 05:30:36 UTC (rev 77324)
@@ -5,9 +5,14 @@
Version 1.5.0 (??/??/2007)
-------------------------
+- Feature: Reviewed all widget attributes. Added all available HTML attributes
+ to the widgets.
+
- Bug/Feature: Correctly create labels for radio button choices.
+- Bug: Added tests for textarea widget.
+
Version 1.4.0 (6/29/2007)
-------------------------
Modified: z3c.form/trunk/src/z3c/form/browser/README.txt
===================================================================
--- z3c.form/trunk/src/z3c/form/browser/README.txt 2007-07-03 02:36:45 UTC (rev 77323)
+++ z3c.form/trunk/src/z3c/form/browser/README.txt 2007-07-03 05:30:36 UTC (rev 77324)
@@ -28,8 +28,8 @@
... request = TestRequest()
... widget = zope.component.getMultiAdapter((field, request),
... interfaces.IFieldWidget)
- ... widget.id = u'foo'
- ... widget.name = u'bar'
+ ... widget.id = 'foo'
+ ... widget.name = 'bar'
... return widget
@@ -94,8 +94,8 @@
>>> from z3c.form.browser import checkbox
>>> widget = checkbox.CheckBoxFieldWidget(field, TestRequest())
- >>> widget.id = u'foo'
- >>> widget.name = u'bar'
+ >>> widget.id = 'foo'
+ >>> widget.name = 'bar'
>>> widget.update()
>>> print widget.render()
@@ -103,11 +103,15 @@
<input type="checkbox" id="foo-0" name="bar:list"
class="checkBoxWidget" value="yes"
checked="checked" />
- <span class="label">yes</span>
+ <label for="foo-0">
+ <span class="label">yes</span>
+ </label>
</span><span class="option">
<input type="checkbox" id="foo-1" name="bar:list"
class="checkBoxWidget" value="no" />
- <span class="label">no</span>
+ <label for="foo-1">
+ <span class="label">no</span>
+ </label>
</span>
<input name="bar-empty-marker" type="hidden" value="1" />
@@ -172,7 +176,7 @@
>>> widget = setupWidget(field)
>>> widget.update()
>>> print widget.render()
- <select id="foo" name="bar:list" class="selectWidget"
+ <select id="foo" name="bar:list" class="selectWidget"
size="1">
<option id="foo-0" value="yes" selected="selected">Yes</option>
<option id="foo-1" value="no">No</option>
@@ -277,7 +281,7 @@
>>> widget = setupWidget(field)
>>> widget.update()
>>> print widget.render()
- <select id="foo" name="bar:list" class="selectWidget"
+ <select id="foo" name="bar:list" class="selectWidget"
multiple="multiple" size="5">
<option id="foo-0" value="1" selected="selected">1</option>
<option id="foo-1" value="2">2</option>
@@ -338,7 +342,7 @@
<tr>
<td>
<select id="foo-from" name="bar.from" size="5"
- multiple="">
+ multiple="multiple">
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
@@ -355,7 +359,7 @@
onclick="javascript:to2from('foo')"><- </button>
</td>
<td>
- <select id="foo-to" name="bar.to" size="5" multiple="">
+ <select id="foo-to" name="bar.to" size="5" multiple="multiple">
<option value="1">1</option>
<option value="3">3</option>
</select>
@@ -411,7 +415,7 @@
>>> widget = setupWidget(field)
>>> widget.update()
>>> print widget.render()
- <select id="foo" name="bar:list" class="selectWidget"
+ <select id="foo" name="bar:list" class="selectWidget"
multiple="multiple" size="5">
<option id="foo-0" value="1" selected="selected">1</option>
<option id="foo-1" value="2">2</option>
@@ -518,7 +522,7 @@
<tr>
<td>
<select id="foo-from" name="bar.from" size="5"
- multiple="">
+ multiple="multiple">
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
@@ -535,7 +539,7 @@
onclick="javascript:to2from('foo')"><- </button>
</td>
<td>
- <select id="foo-to" name="bar.to" size="5" multiple="">
+ <select id="foo-to" name="bar.to" size="5" multiple="multiple">
<option value="1">1</option>
<option value="3">3</option>
</select>
Modified: z3c.form/trunk/src/z3c/form/browser/checkbox.py
===================================================================
--- z3c.form/trunk/src/z3c/form/browser/checkbox.py 2007-07-03 02:36:45 UTC (rev 77323)
+++ z3c.form/trunk/src/z3c/form/browser/checkbox.py 2007-07-03 05:30:36 UTC (rev 77324)
@@ -23,19 +23,15 @@
import zope.schema.interfaces
from zope.i18n import translate
-from z3c.form import interfaces
-from z3c.form import widget
+from z3c.form import interfaces, widget
+from z3c.form.browser.widget import HTMLInputWidget
-class CheckBoxWidget(widget.SequenceWidget):
+class CheckBoxWidget(HTMLInputWidget, widget.SequenceWidget):
"""Input type checkbox widget implementation."""
-
zope.interface.implementsOnly(interfaces.ICheckBoxWidget)
css = u'checkBoxWidget'
- alt = None
- readonly = None
- accesskey = None
items = ()
def isChecked(self, term):
Modified: z3c.form/trunk/src/z3c/form/browser/checkbox.txt
===================================================================
--- z3c.form/trunk/src/z3c/form/browser/checkbox.txt 2007-07-03 02:36:45 UTC (rev 77323)
+++ z3c.form/trunk/src/z3c/form/browser/checkbox.txt 2007-07-03 05:30:36 UTC (rev 77324)
@@ -27,8 +27,8 @@
Set a name and id for the widget:
- >>> widget.id = u'widget-id'
- >>> widget.name = u'widget.name'
+ >>> widget.id = 'widget-id'
+ >>> widget.name = 'widget.name'
Such a field provides IWidget:
@@ -56,7 +56,8 @@
<input name="widget.name-empty-marker" type="hidden" value="1" />
Let's provide some values for this widget. We can do this by defining a source
-providing ITerms. This source uses descriminators wich will fit for our setup.
+providing ``ITerms``. This source uses descriminators wich will fit for our
+setup.
>>> import zope.schema.interfaces
>>> from zope.schema.vocabulary import SimpleVocabulary
@@ -76,11 +77,15 @@
<span class="option">
<input type="checkbox" id="widget-id-0" name="widget.name:list"
class="checkBoxWidget" value="yes" />
- <span class="label">yes</span>
+ <label for="widget-id-0">
+ <span class="label">yes</span>
+ </label>
</span><span class="option">
<input type="checkbox" id="widget-id-1" name="widget.name:list"
class="checkBoxWidget" value="no" />
- <span class="label">no</span>
+ <label for="widget-id-1">
+ <span class="label">no</span>
+ </label>
</span>
<input name="widget.name-empty-marker" type="hidden" value="1" />
@@ -94,10 +99,14 @@
<input type="checkbox" id="widget-id-0" name="widget.name:list"
class="checkBoxWidget" value="yes"
checked="checked" />
- <span class="label">yes</span>
+ <label for="widget-id-0">
+ <span class="label">yes</span>
+ </label>
</span><span class="option">
<input type="checkbox" id="widget-id-1" name="widget.name:list"
class="checkBoxWidget" value="no" />
- <span class="label">no</span>
+ <label for="widget-id-1">
+ <span class="label">no</span>
+ </label>
</span>
<input name="widget.name-empty-marker" type="hidden" value="1" />
Modified: z3c.form/trunk/src/z3c/form/browser/checkbox_input.pt
===================================================================
--- z3c.form/trunk/src/z3c/form/browser/checkbox_input.pt 2007-07-03 02:36:45 UTC (rev 77323)
+++ z3c.form/trunk/src/z3c/form/browser/checkbox_input.pt 2007-07-03 05:30:36 UTC (rev 77324)
@@ -1,32 +1,66 @@
<span class="option"
tal:repeat="item view/items">
- <input type="checkbox" id="" name="" class=""
- alt="" title="" tabindex="" disabled="" readonly="" accesskey="" value="" checked="checked"
+ <input type="checkbox" id="" name="" class="" alt="" title=""
+ tabindex="" disabled="" readonly="" accesskey="" value=""
+ checked="checked"
tal:condition="item/checked"
tal:attributes="id item/id;
name item/name;
+ value item/value;
class view/css;
- alt view/alt;
title view/title;
+ lang view/lang;
+ onclick view/onclick;
+ ondblclick view/ondblclick;
+ onmousedown view/onmousedown;
+ onmouseup view/onmouseup;
+ onmouseover view/onmouseover;
+ onmousemove view/onmousemove;
+ onmouseout view/onmouseout;
+ onkeypress view/onkeypress;
+ onkeydown view/onkeydown;
+ onkeyup view/onkeyup;
+ disabled view/disabled;
tabindex view/tabindex;
- disabled view/disabled;
+ onfocus view/onfocus;
+ onblur view/onblur;
+ onchange view/onchange;
readonly view/readonly;
+ alt view/alt;
accesskey view/accesskey;
- value item/value"
- /><input type="checkbox" id="" name="" class=""
- alt="" title="" tabindex="" disabled="" readonly="" accesskey="" value=""
+ onselect view/onselect"
+ /><input type="checkbox" id="" name="" class="" alt="" title="" tabindex=""
+ disabled="" readonly="" accesskey="" value=""
tal:condition="not:item/checked"
tal:attributes="id item/id;
name item/name;
+ value item/value;
class view/css;
- alt view/alt;
title view/title;
+ lang view/lang;
+ onclick view/onclick;
+ ondblclick view/ondblclick;
+ onmousedown view/onmousedown;
+ onmouseup view/onmouseup;
+ onmouseover view/onmouseover;
+ onmousemove view/onmousemove;
+ onmouseout view/onmouseout;
+ onkeypress view/onkeypress;
+ onkeydown view/onkeydown;
+ onkeyup view/onkeyup;
+ disabled view/disabled;
tabindex view/tabindex;
- disabled view/disabled;
+ onfocus view/onfocus;
+ onblur view/onblur;
+ onchange view/onchange;
readonly view/readonly;
+ alt view/alt;
accesskey view/accesskey;
- value item/value" />
- <span class="label" tal:content="item/label">Label</span>
+ onselect view/onselect" />
+ <label for=""
+ tal:attributes="for item/id">
+ <span class="label" tal:content="item/label">Label</span>
+ </label>
</span>
<input name="field-empty-marker" type="hidden" value="1"
tal:attributes="name string:${view/name}-empty-marker" />
Modified: z3c.form/trunk/src/z3c/form/browser/file.py
===================================================================
--- z3c.form/trunk/src/z3c/form/browser/file.py 2007-07-03 02:36:45 UTC (rev 77323)
+++ z3c.form/trunk/src/z3c/form/browser/file.py 2007-07-03 05:30:36 UTC (rev 77324)
@@ -28,8 +28,8 @@
"""Input type text widget implementation."""
zope.interface.implementsOnly(interfaces.IFileWidget)
- # filename and headers attribute get set by IDataConverter to the widget
- # providedy form the FileUpload
+ # Filename and headers attribute get set by ``IDataConverter`` to the widget
+ # provided by the FileUpload object of the form.
headers = None
filename = None
css = u'fileWidget'
Modified: z3c.form/trunk/src/z3c/form/browser/file.txt
===================================================================
--- z3c.form/trunk/src/z3c/form/browser/file.txt 2007-07-03 02:36:45 UTC (rev 77323)
+++ z3c.form/trunk/src/z3c/form/browser/file.txt 2007-07-03 05:30:36 UTC (rev 77324)
@@ -26,8 +26,8 @@
Before rendering the widget, one has to set the name and id of the widget:
- >>> widget.id = u'widget.id'
- >>> widget.name = u'widget.name'
+ >>> widget.id = 'widget.id'
+ >>> widget.name = 'widget.name'
We also need to register the template for the widget:
Modified: z3c.form/trunk/src/z3c/form/browser/file_input.pt
===================================================================
--- z3c.form/trunk/src/z3c/form/browser/file_input.pt 2007-07-03 02:36:45 UTC (rev 77323)
+++ z3c.form/trunk/src/z3c/form/browser/file_input.pt 2007-07-03 05:30:36 UTC (rev 77324)
@@ -1,13 +1,28 @@
-<input type="file" id="" name="" class="" size="" alt="" title=""
- tabindex="" disabled="" readonly="" accesskey="" maxlength=""
+<input type="file" id="" name="" class="" title="" lang="" disabled=""
+ readonly="" alt="" tabindex="" accesskey="" size="" maxlength=""
tal:attributes="id view/id;
name view/name;
- class view/css;
+ class view/css;
title view/title;
- alt view/alt;
+ lang view/lang;
+ onclick view/onclick;
+ ondblclick view/ondblclick;
+ onmousedown view/onmousedown;
+ onmouseup view/onmouseup;
+ onmouseover view/onmouseover;
+ onmousemove view/onmousemove;
+ onmouseout view/onmouseout;
+ onkeypress view/onkeypress;
+ onkeydown view/onkeydown;
+ onkeyup view/onkeyup;
+ disabled view/disabled;
tabindex view/tabindex;
- disabled view/disabled;
+ onfocus view/onfocus;
+ onblur view/onblur;
+ onchange view/onchange;
readonly view/readonly;
+ alt view/alt;
accesskey view/accesskey;
- maxlength view/maxlength;
- size view/size" />
+ onselect view/onselect;
+ size view/size;
+ maxlength view/maxlength" />
Added: z3c.form/trunk/src/z3c/form/browser/interfaces.py
===================================================================
--- z3c.form/trunk/src/z3c/form/browser/interfaces.py (rev 0)
+++ z3c.form/trunk/src/z3c/form/browser/interfaces.py 2007-07-03 05:30:36 UTC (rev 77324)
@@ -0,0 +1,268 @@
+##############################################################################
+#
+# Copyright (c) 2007 Zope Foundation and Contributors.
+# All Rights Reserved.
+#
+# This software is subject to the provisions of the Zope Public License,
+# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution.
+# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
+# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
+# FOR A PARTICULAR PURPOSE.
+#
+##############################################################################
+"""Browser Widget Framework Interfaces
+
+$Id$
+"""
+__docformat__ = "reStructuredText"
+import zope.interface
+import zope.schema
+
+
+class IHTMLCoreAttributes(zope.interface.Interface):
+ """The HTML element 'core' attributes."""
+
+ id = zope.schema.BytesLine(
+ title=u'Id',
+ description=(u'This attribute assigns a name to an element. This '
+ u'name must be unique in a document.'),
+ required=False)
+
+ # HTML "class" attribute; "class" is a keyword in Python.
+ css = zope.schema.TextLine(
+ title=u'Class',
+ description=(u'This attribute assigns a class name or set of '
+ u'class names to an element. Any number of elements '
+ u'may be assigned the same class name or names.'),
+ required=False)
+
+ style = zope.schema.TextLine(
+ title=u'Style',
+ description=(u'This attribute offers advisory information about '
+ u'the element for which it is set.'),
+ required=False)
+
+ title = zope.schema.TextLine(
+ title=u'Title',
+ description=(u'This attribute offers advisory information about '
+ u'the element for which it is set.'),
+ required=False)
+
+
+class IHTMLI18nAttributes(zope.interface.Interface):
+ """The HTML element 'i18n' attributes."""
+
+ lang = zope.schema.TextLine(
+ title=u'Language',
+ description=(u"This attribute specifies the base language of an "
+ u"element's attribute values and text content."),
+ required=False)
+
+
+class IHTMLEventsAttributes(zope.interface.Interface):
+ """The HTML element 'events' attributes."""
+
+ onclick = zope.schema.TextLine(
+ title=u'On Click',
+ description=(u'The ``onclick`` event occurs when the pointing device '
+ u'button is clicked over an element.'),
+ required=False)
+
+ ondblclick = zope.schema.TextLine(
+ title=u'On Double-Click',
+ description=(u'The ``ondblclick`` event occurs when the pointing '
+ u'device button is double clicked over an element.'),
+ required=False)
+
+ onmousedown = zope.schema.TextLine(
+ title=u'On Mouse Down',
+ description=(u'The onmousedown event occurs when the pointing '
+ u'device button is pressed over an element.'),
+ required=False)
+
+ onmouseup = zope.schema.TextLine(
+ title=u'On Mouse Up',
+ description=(u'The ``onmouseup`` event occurs when the pointing '
+ u'device button is released over an element.'),
+ required=False)
+
+ onmouseover = zope.schema.TextLine(
+ title=u'On Mouse Over',
+ description=(u'The ``onmouseover`` event occurs when the pointing '
+ u'device is moved onto an element.'),
+ required=False)
+
+ onmousemove = zope.schema.TextLine(
+ title=u'On Mouse Move',
+ description=(u'The ``onmousemove`` event occurs when the pointing '
+ u'device is moved while it is over an element.'),
+ required=False)
+
+ onmouseout = zope.schema.TextLine(
+ title=u'On Mouse Out',
+ description=(u'The ``onmouseout`` event occurs when the pointing '
+ u'device is moved away from an element.'),
+ required=False)
+
+ onkeypress = zope.schema.TextLine(
+ title=u'On Key Press',
+ description=(u'The ``onkeypress`` event occurs when a key is '
+ u'pressed and released over an element.'),
+ required=False)
+
+ onkeydown = zope.schema.TextLine(
+ title=u'On Key Down',
+ description=(u'The ``onkeydown`` event occurs when a key is pressed '
+ u'down over an element.'),
+ required=False)
+
+ onkeyup = zope.schema.TextLine(
+ title=u'On Key Up',
+ description=(u'The ``onkeyup`` event occurs when a key is released '
+ u'over an element.'),
+ required=False)
+
+
+class IHTMLFormElement(IHTMLCoreAttributes,
+ IHTMLI18nAttributes,
+ IHTMLEventsAttributes):
+ """A generic form-related element."""
+
+ disabled = zope.schema.Choice(
+ title=u'Disabled',
+ description=(u'When set for a form control, this boolean attribute '
+ u'disables the control for user input.'),
+ values=(None, 'disabled'),
+ required=False)
+
+ tabindex = zope.schema.Int(
+ title=u'Tab Index',
+ description=(u'This attribute specifies the position of the current '
+ u'element in the tabbing order for the current '
+ u'document. This value must be a number between 0 and '
+ u'32767.'),
+ required=False)
+
+ onfocus = zope.schema.TextLine(
+ title=u'On Focus',
+ description=(u'The ``onfocus`` event occurs when an element receives '
+ u'focus either by the pointing device or by tabbing '
+ u'navigation.'),
+ required=False)
+
+ onblur = zope.schema.TextLine(
+ title=u'On blur',
+ description=(u'The ``onblur`` event occurs when an element loses '
+ u'focus either by the pointing device or by tabbing '
+ u'navigation.'),
+ required=False)
+
+ onchange = zope.schema.TextLine(
+ title=u'On Change',
+ description=(u'The onchange event occurs when a control loses the '
+ u'input focus and its value has been modified since '
+ u'gaining focus.'),
+ required=False)
+
+
+class IHTMLInputWidget(IHTMLFormElement):
+ """A widget using the HTML INPUT element."""
+
+ readonly = zope.schema.Choice(
+ title=u'Read-Only',
+ description=(u'When set for a form control, this boolean attribute '
+ u'prohibits changes to the control.'),
+ values=(None, 'readonly'),
+ required=False)
+
+ alt = zope.schema.TextLine(
+ title=u'Alternate Text',
+ description=(u'For user agents that cannot display images, forms, '
+ u'or applets, this attribute specifies alternate text.'),
+ required=False)
+
+ accesskey = zope.schema.TextLine(
+ title=u'Access Key',
+ description=(u'This attribute assigns an access key to an element.'),
+ min_length=1,
+ max_length=1,
+ required=False)
+
+ onselect = zope.schema.TextLine(
+ title=u'On Select',
+ description=(u'The ``onselect`` event occurs when a user selects '
+ u'some text in a text field.'),
+ required=False)
+
+
+class IHTMLTextInputWidget(IHTMLFormElement):
+ """A widget using the HTML INPUT element (for text types)."""
+
+ size = zope.schema.Int(
+ title=u'Size',
+ description=(u'This attribute tells the user agent the initial width '
+ u'of the control -- in this case in characters.'),
+ required=False)
+
+ maxlength = zope.schema.Int(
+ title=u'Maximum Length',
+ description=(u'This attribute specifies the maximum number of '
+ u'characters the user may enter.'),
+ required=False)
+
+
+class IHTMLTextAreaWidget(IHTMLFormElement):
+ """A widget using the HTML TEXTAREA element."""
+
+ rows = zope.schema.Int(
+ title=u'Rows',
+ description=(u'This attribute specifies the number of visible text '
+ u'lines.'),
+ required=False)
+
+ cols = zope.schema.Int(
+ title=u'columns',
+ description=(u'This attribute specifies the visible width in average '
+ u'character widths.'),
+ required=False)
+
+ readonly = zope.schema.Choice(
+ title=u'Read-Only',
+ description=(u'When set for a form control, this boolean attribute '
+ u'prohibits changes to the control.'),
+ values=(None, 'readonly'),
+ required=False)
+
+ accesskey = zope.schema.TextLine(
+ title=u'Access Key',
+ description=(u'This attribute assigns an access key to an element.'),
+ min_length=1,
+ max_length=1,
+ required=False)
+
+ onselect = zope.schema.TextLine(
+ title=u'On Select',
+ description=(u'The ``onselect`` event occurs when a user selects '
+ u'some text in a text field.'),
+ required=False)
+
+
+class IHTMLSelectWidget(IHTMLFormElement):
+ """A widget using the HTML SELECT element."""
+
+ multiple = zope.schema.Choice(
+ title=u'Multiple',
+ description=(u'If set, this boolean attribute allows multiple '
+ u'selections.'),
+ values=(None, 'multiple'),
+ required=False)
+
+ size = zope.schema.Int(
+ title=u'Size',
+ description=(u'If a SELECT element is presented as a scrolled '
+ u'list box, this attribute specifies the number of '
+ u'rows in the list that should be visible at the '
+ u'same time.'),
+ default=1,
+ required=False)
Property changes on: z3c.form/trunk/src/z3c/form/browser/interfaces.py
___________________________________________________________________
Name: svn:keywords
+ Id
Modified: z3c.form/trunk/src/z3c/form/browser/orderedselect.py
===================================================================
--- z3c.form/trunk/src/z3c/form/browser/orderedselect.py 2007-07-03 02:36:45 UTC (rev 77323)
+++ z3c.form/trunk/src/z3c/form/browser/orderedselect.py 2007-07-03 05:30:36 UTC (rev 77324)
@@ -23,14 +23,15 @@
from zope.i18n import translate
from z3c.form import interfaces, widget
+from z3c.form.browser.widget import HTMLSelectWidget
-class OrderedSelectWidget(widget.SequenceWidget):
+class OrderedSelectWidget(HTMLSelectWidget, widget.SequenceWidget):
"""Ordered-Select widget implementation."""
zope.interface.implementsOnly(interfaces.IOrderedSelectWidget)
size = 5
- multiple = True
+ multiple = u'multiple'
items = ()
selectedItems = ()
Modified: z3c.form/trunk/src/z3c/form/browser/orderedselect.txt
===================================================================
--- z3c.form/trunk/src/z3c/form/browser/orderedselect.txt 2007-07-03 02:36:45 UTC (rev 77323)
+++ z3c.form/trunk/src/z3c/form/browser/orderedselect.txt 2007-07-03 05:30:36 UTC (rev 77324)
@@ -26,8 +26,8 @@
Before rendering the widget, one has to set the name and id of the widget:
- >>> widget.id = u'widget-id'
- >>> widget.name = u'widget.name'
+ >>> widget.id = 'widget-id'
+ >>> widget.name = 'widget.name'
We also need to register the template for at least the widget and request:
@@ -51,7 +51,7 @@
<tr>
<td>
<select id="widget-id-from" name="widget.name.from"
- size="5" multiple="">
+ size="5" multiple="multiple">
</select>
</td>
<td>
@@ -65,7 +65,7 @@
</td>
<td>
<select id="widget-id-to" name="widget.name.to"
- size="5" multiple="">
+ size="5" multiple="multiple">
</select>
<input name="widget.name-empty-marker" type="hidden" />
<span id="widget-id-toDataContainer">
@@ -113,7 +113,7 @@
<tr>
<td>
<select id="widget-id-from" name="widget.name.from"
- size="5" multiple="">
+ size="5" multiple="multiple">
<option value="a">A</option>
<option value="b">B</option>
<option value="c">C</option>
@@ -135,7 +135,7 @@
<tr>
<td>
<select id="widget-id-from" name="widget.name.from"
- size="5" multiple="">
+ size="5" multiple="multiple">
<option value="a">A</option>
<option value="b">B</option>
<option value="c">C</option>
@@ -144,7 +144,7 @@
...
<td>
<select id="widget-id-to" name="widget.name.to"
- size="5" multiple="">
+ size="5" multiple="multiple">
<option value="b">B</option>
</select>
<input name="widget.name-empty-marker" type="hidden" />
Modified: z3c.form/trunk/src/z3c/form/browser/orderedselect_input.pt
===================================================================
--- z3c.form/trunk/src/z3c/form/browser/orderedselect_input.pt 2007-07-03 02:36:45 UTC (rev 77323)
+++ z3c.form/trunk/src/z3c/form/browser/orderedselect_input.pt 2007-07-03 05:30:36 UTC (rev 77324)
@@ -142,7 +142,27 @@
<td>
<select id="from" name="from" size="5" multiple=""
tal:attributes="name string:${view/name}.from;
- id string:${view/id}-from">
+ id string:${view/id}-from;
+ class view/css;
+ title view/title;
+ lang view/lang;
+ onclick view/onclick;
+ ondblclick view/ondblclick;
+ onmousedown view/onmousedown;
+ onmouseup view/onmouseup;
+ onmouseover view/onmouseover;
+ onmousemove view/onmousemove;
+ onmouseout view/onmouseout;
+ onkeypress view/onkeypress;
+ onkeydown view/onkeydown;
+ onkeyup view/onkeyup;
+ disabled view/disabled;
+ tabindex view/tabindex;
+ onfocus view/onfocus;
+ onblur view/onblur;
+ onchange view/onchange;
+ multiple view/multiple;
+ size view/size">
<option tal:repeat="entry view/items"
tal:attributes="value entry/value"
tal:content="entry/content" i18n:translate=""/>
@@ -162,7 +182,27 @@
<td>
<select id="to" name="to" size="5" multiple=""
tal:attributes="name string:${view/name}.to;
- id string:${view/id}-to">
+ id string:${view/id}-to;
+ class view/css;
+ title view/title;
+ lang view/lang;
+ onclick view/onclick;
+ ondblclick view/ondblclick;
+ onmousedown view/onmousedown;
+ onmouseup view/onmouseup;
+ onmouseover view/onmouseover;
+ onmousemove view/onmousemove;
+ onmouseout view/onmouseout;
+ onkeypress view/onkeypress;
+ onkeydown view/onkeydown;
+ onkeyup view/onkeyup;
+ disabled view/disabled;
+ tabindex view/tabindex;
+ onfocus view/onfocus;
+ onblur view/onblur;
+ onchange view/onchange;
+ multiple view/multiple;
+ size view/size">
<option tal:repeat="entry view/selectedItems"
tal:attributes="value entry/value"
tal:content="entry/content" i18n:translate=""/>
Modified: z3c.form/trunk/src/z3c/form/browser/password.txt
===================================================================
--- z3c.form/trunk/src/z3c/form/browser/password.txt 2007-07-03 02:36:45 UTC (rev 77323)
+++ z3c.form/trunk/src/z3c/form/browser/password.txt 2007-07-03 05:30:36 UTC (rev 77324)
@@ -26,8 +26,8 @@
Before rendering the widget, one has to set the name and id of the widget:
- >>> widget.id = u'widget.id'
- >>> widget.name = u'widget.name'
+ >>> widget.id = 'widget.id'
+ >>> widget.name = 'widget.name'
We also need to register the template for the widget:
Modified: z3c.form/trunk/src/z3c/form/browser/password_input.pt
===================================================================
--- z3c.form/trunk/src/z3c/form/browser/password_input.pt 2007-07-03 02:36:45 UTC (rev 77323)
+++ z3c.form/trunk/src/z3c/form/browser/password_input.pt 2007-07-03 05:30:36 UTC (rev 77324)
@@ -1,13 +1,28 @@
-<input type="password" id="" name="" class="" size="" alt="" title=""
- tabindex="" disabled="" readonly="" accesskey="" maxlength=""
+<input type="password" id="" name="" class="" title="" lang="" disabled=""
+ readonly="" alt="" tabindex="" accesskey="" size="" maxlength=""
tal:attributes="id view/id;
name view/name;
- class view/css;
+ class view/css;
title view/title;
- alt view/alt;
+ lang view/lang;
+ onclick view/onclick;
+ ondblclick view/ondblclick;
+ onmousedown view/onmousedown;
+ onmouseup view/onmouseup;
+ onmouseover view/onmouseover;
+ onmousemove view/onmousemove;
+ onmouseout view/onmouseout;
+ onkeypress view/onkeypress;
+ onkeydown view/onkeydown;
+ onkeyup view/onkeyup;
+ disabled view/disabled;
tabindex view/tabindex;
- disabled view/disabled;
+ onfocus view/onfocus;
+ onblur view/onblur;
+ onchange view/onchange;
readonly view/readonly;
+ alt view/alt;
accesskey view/accesskey;
- maxlength view/maxlength;
- size view/size" />
+ onselect view/onselect;
+ size view/size;
+ maxlength view/maxlength" />
Modified: z3c.form/trunk/src/z3c/form/browser/radio.py
===================================================================
--- z3c.form/trunk/src/z3c/form/browser/radio.py 2007-07-03 02:36:45 UTC (rev 77323)
+++ z3c.form/trunk/src/z3c/form/browser/radio.py 2007-07-03 05:30:36 UTC (rev 77324)
@@ -23,19 +23,15 @@
import zope.schema.interfaces
from zope.i18n import translate
-from z3c.form import interfaces
-from z3c.form import widget
+from z3c.form import interfaces, widget
+from z3c.form.browser.widget import HTMLInputWidget
-class RadioWidget(widget.SequenceWidget):
+class RadioWidget(HTMLInputWidget, widget.SequenceWidget):
"""Input type radio widget implementation."""
-
zope.interface.implementsOnly(interfaces.IRadioWidget)
css = u'radioWidget'
- alt = None
- readonly = None
- accesskey = None
items = ()
def isChecked(self, term):
Modified: z3c.form/trunk/src/z3c/form/browser/radio.txt
===================================================================
--- z3c.form/trunk/src/z3c/form/browser/radio.txt 2007-07-03 02:36:45 UTC (rev 77323)
+++ z3c.form/trunk/src/z3c/form/browser/radio.txt 2007-07-03 05:30:36 UTC (rev 77324)
@@ -22,8 +22,8 @@
Set a name and id for the widget:
- >>> widget.id = u'widget-id'
- >>> widget.name = u'widget.name'
+ >>> widget.id = 'widget-id'
+ >>> widget.name = 'widget.name'
Such a field provides IWidget:
Modified: z3c.form/trunk/src/z3c/form/browser/radio_input.pt
===================================================================
--- z3c.form/trunk/src/z3c/form/browser/radio_input.pt 2007-07-03 02:36:45 UTC (rev 77323)
+++ z3c.form/trunk/src/z3c/form/browser/radio_input.pt 2007-07-03 05:30:36 UTC (rev 77324)
@@ -1,31 +1,62 @@
<span class="option"
tal:repeat="item view/items">
- <input type="radio" id="" name="" class="" alt="" title="" tabindex=""
- disabled="" readonly="" accesskey="" value="" checked="checked"
+ <input type="radio" id="" name="" class="" alt="" title=""
+ tabindex="" disabled="" readonly="" accesskey="" value=""
+ checked="checked"
tal:condition="item/checked"
tal:attributes="id item/id;
name item/name;
+ value item/value;
class view/css;
- alt view/alt;
title view/title;
+ lang view/lang;
+ onclick view/onclick;
+ ondblclick view/ondblclick;
+ onmousedown view/onmousedown;
+ onmouseup view/onmouseup;
+ onmouseover view/onmouseover;
+ onmousemove view/onmousemove;
+ onmouseout view/onmouseout;
+ onkeypress view/onkeypress;
+ onkeydown view/onkeydown;
+ onkeyup view/onkeyup;
+ disabled view/disabled;
tabindex view/tabindex;
- disabled view/disabled;
+ onfocus view/onfocus;
+ onblur view/onblur;
+ onchange view/onchange;
readonly view/readonly;
+ alt view/alt;
accesskey view/accesskey;
- value item/value"
+ onselect view/onselect"
/><input type="radio" id="" name="" class="" alt="" title="" tabindex=""
- disabled="" readonly="" accesskey="" value=""
+ disabled="" readonly="" accesskey="" value=""
tal:condition="not:item/checked"
tal:attributes="id item/id;
name item/name;
+ value item/value;
class view/css;
- alt view/alt;
title view/title;
+ lang view/lang;
+ onclick view/onclick;
+ ondblclick view/ondblclick;
+ onmousedown view/onmousedown;
+ onmouseup view/onmouseup;
+ onmouseover view/onmouseover;
+ onmousemove view/onmousemove;
+ onmouseout view/onmouseout;
+ onkeypress view/onkeypress;
+ onkeydown view/onkeydown;
+ onkeyup view/onkeyup;
+ disabled view/disabled;
tabindex view/tabindex;
- disabled view/disabled;
+ onfocus view/onfocus;
+ onblur view/onblur;
+ onchange view/onchange;
readonly view/readonly;
+ alt view/alt;
accesskey view/accesskey;
- value item/value" />
+ onselect view/onselect" />
<label for=""
tal:attributes="for item/id">
<span class="label" tal:content="item/label">Label</span>
Modified: z3c.form/trunk/src/z3c/form/browser/select.py
===================================================================
--- z3c.form/trunk/src/z3c/form/browser/select.py 2007-07-03 02:36:45 UTC (rev 77323)
+++ z3c.form/trunk/src/z3c/form/browser/select.py 2007-07-03 05:30:36 UTC (rev 77324)
@@ -24,16 +24,14 @@
from z3c.form import interfaces, widget
from z3c.form.i18n import MessageFactory as _
+from z3c.form.browser.widget import HTMLSelectWidget
-class SelectWidget(widget.SequenceWidget):
+class SelectWidget(HTMLSelectWidget, widget.SequenceWidget):
"""Select widget implementation."""
-
zope.interface.implementsOnly(interfaces.ISelectWidget)
css = u'selectWidget'
- size = 1
- multiple = None
items = ()
prompt = False
Modified: z3c.form/trunk/src/z3c/form/browser/select.txt
===================================================================
--- z3c.form/trunk/src/z3c/form/browser/select.txt 2007-07-03 02:36:45 UTC (rev 77323)
+++ z3c.form/trunk/src/z3c/form/browser/select.txt 2007-07-03 05:30:36 UTC (rev 77324)
@@ -26,8 +26,8 @@
Before rendering the widget, one has to set the name and id of the widget:
- >>> widget.id = u'widget-id'
- >>> widget.name = u'widget.name'
+ >>> widget.id = 'widget-id'
+ >>> widget.name = 'widget.name'
We also need to register the template for at least the widget and request:
Modified: z3c.form/trunk/src/z3c/form/browser/select_input.pt
===================================================================
--- z3c.form/trunk/src/z3c/form/browser/select_input.pt 2007-07-03 02:36:45 UTC (rev 77323)
+++ z3c.form/trunk/src/z3c/form/browser/select_input.pt 2007-07-03 05:30:36 UTC (rev 77324)
@@ -2,8 +2,23 @@
tal:attributes="id view/id;
name string:${view/name}:list;
class view/css;
+ title view/title;
+ lang view/lang;
+ onclick view/onclick;
+ ondblclick view/ondblclick;
+ onmousedown view/onmousedown;
+ onmouseup view/onmouseup;
+ onmouseover view/onmouseover;
+ onmousemove view/onmousemove;
+ onmouseout view/onmouseout;
+ onkeypress view/onkeypress;
+ onkeydown view/onkeydown;
+ onkeyup view/onkeyup;
+ disabled view/disabled;
tabindex view/tabindex;
- disabled view/disabled;
+ onfocus view/onfocus;
+ onblur view/onblur;
+ onchange view/onchange;
multiple view/multiple;
size view/size">
<tal:block repeat="item view/items"
Modified: z3c.form/trunk/src/z3c/form/browser/submit.py
===================================================================
--- z3c.form/trunk/src/z3c/form/browser/submit.py 2007-07-03 02:36:45 UTC (rev 77323)
+++ z3c.form/trunk/src/z3c/form/browser/submit.py 2007-07-03 05:30:36 UTC (rev 77324)
@@ -18,17 +18,19 @@
__docformat__ = "reStructuredText"
import zope.component
import zope.interface
+
from z3c.form import interfaces, widget
+from z3c.form.browser.widget import HTMLInputWidget
-class SubmitWidget(widget.Widget):
+class SubmitWidget(HTMLInputWidget, widget.Widget):
"""A submit button of a form."""
zope.interface.implementsOnly(interfaces.ISubmitWidget)
css = u'submitWidget'
- accesskey = None
+
@zope.component.adapter(interfaces.IButton, interfaces.IFormLayer)
@zope.interface.implementer(interfaces.IFieldWidget)
def SubmitFieldWidget(field, request):
Modified: z3c.form/trunk/src/z3c/form/browser/submit.txt
===================================================================
--- z3c.form/trunk/src/z3c/form/browser/submit.txt 2007-07-03 02:36:45 UTC (rev 77323)
+++ z3c.form/trunk/src/z3c/form/browser/submit.txt 2007-07-03 05:30:36 UTC (rev 77324)
@@ -26,8 +26,8 @@
Before rendering the widget, one has to set the name and id of the widget:
- >>> widget.id = u'widget.id'
- >>> widget.name = u'widget.name'
+ >>> widget.id = 'widget.id'
+ >>> widget.name = 'widget.name'
We also need to register the template for the widget:
Modified: z3c.form/trunk/src/z3c/form/browser/submit_input.pt
===================================================================
--- z3c.form/trunk/src/z3c/form/browser/submit_input.pt 2007-07-03 02:36:45 UTC (rev 77323)
+++ z3c.form/trunk/src/z3c/form/browser/submit_input.pt 2007-07-03 05:30:36 UTC (rev 77324)
@@ -3,6 +3,24 @@
tal:attributes="id view/id;
name view/name;
class view/css;
+ lang view/lang;
+ onclick view/onclick;
+ ondblclick view/ondblclick;
+ onmousedown view/onmousedown;
+ onmouseup view/onmouseup;
+ onmouseover view/onmouseover;
+ onmousemove view/onmousemove;
+ onmouseout view/onmouseout;
+ onkeypress view/onkeypress;
+ onkeydown view/onkeydown;
+ onkeyup view/onkeyup;
value view/value;
+ disabled view/disabled;
+ tabindex view/tabindex;
+ onfocus view/onfocus;
+ onblur view/onblur;
+ onchange view/onchange;
+ readonly view/readonly;
+ alt view/alt;
accesskey view/accesskey;
- " />
+ onselect view/onselect" />
Modified: z3c.form/trunk/src/z3c/form/browser/tests.py
===================================================================
--- z3c.form/trunk/src/z3c/form/browser/tests.py 2007-07-03 02:36:45 UTC (rev 77323)
+++ z3c.form/trunk/src/z3c/form/browser/tests.py 2007-07-03 05:30:36 UTC (rev 77324)
@@ -53,4 +53,8 @@
setUp=testing.setUp, tearDown=testing.tearDown,
optionflags=doctest.NORMALIZE_WHITESPACE|doctest.ELLIPSIS,
),
+ DocFileSuite('textarea.txt',
+ setUp=testing.setUp, tearDown=testing.tearDown,
+ optionflags=doctest.NORMALIZE_WHITESPACE|doctest.ELLIPSIS,
+ ),
))
Modified: z3c.form/trunk/src/z3c/form/browser/text.py
===================================================================
--- z3c.form/trunk/src/z3c/form/browser/text.py 2007-07-03 02:36:45 UTC (rev 77323)
+++ z3c.form/trunk/src/z3c/form/browser/text.py 2007-07-03 05:30:36 UTC (rev 77324)
@@ -21,24 +21,17 @@
import zope.schema.interfaces
from z3c.form import interfaces, widget
+from z3c.form.browser.widget import HTMLTextInputWidget
-
-class TextWidget(widget.Widget):
+class TextWidget(HTMLTextInputWidget, widget.Widget):
"""Input type text widget implementation."""
zope.interface.implementsOnly(interfaces.ITextWidget)
css = u'textWidget'
- size = None
value = u''
- # optional html attributes
- alt = None
- readonly = None
- maxlength = None
- accesskey = None
-
@zope.component.adapter(zope.schema.interfaces.IField, interfaces.IFormLayer)
@zope.interface.implementer(interfaces.IFieldWidget)
def TextFieldWidget(field, request):
Modified: z3c.form/trunk/src/z3c/form/browser/text.txt
===================================================================
--- z3c.form/trunk/src/z3c/form/browser/text.txt 2007-07-03 02:36:45 UTC (rev 77323)
+++ z3c.form/trunk/src/z3c/form/browser/text.txt 2007-07-03 05:30:36 UTC (rev 77324)
@@ -42,5 +42,15 @@
If we render the widget we get the HTML:
- >>> widget.render()
- u'<input type="text" id="" name="" class="textWidget" value="" />\n'
+ >>> print widget.render()
+ <input type="text" class="textWidget" value="" />
+
+Adding some more attributes to the widget will make it display more:
+
+ >>> widget.id = 'id'
+ >>> widget.name = 'name'
+ >>> widget.value = u'value'
+
+ >>> print widget.render()
+ <input type="text" id="id" name="name" class="textWidget"
+ value="value" />
Modified: z3c.form/trunk/src/z3c/form/browser/text_input.pt
===================================================================
--- z3c.form/trunk/src/z3c/form/browser/text_input.pt 2007-07-03 02:36:45 UTC (rev 77323)
+++ z3c.form/trunk/src/z3c/form/browser/text_input.pt 2007-07-03 05:30:36 UTC (rev 77324)
@@ -1,14 +1,29 @@
-<input type="text" id="" name="" class="" size="" alt="" title=""
- tabindex="" disabled="" readonly="" accesskey="" maxlength="" value=""
+<input type="text" id="" name="" class="" title="" lang="" disabled=""
+ readonly="" alt="" tabindex="" accesskey="" size="" maxlength=""
tal:attributes="id view/id;
name view/name;
class view/css;
title view/title;
- alt view/alt;
+ lang view/lang;
+ onclick view/onclick;
+ ondblclick view/ondblclick;
+ onmousedown view/onmousedown;
+ onmouseup view/onmouseup;
+ onmouseover view/onmouseover;
+ onmousemove view/onmousemove;
+ onmouseout view/onmouseout;
+ onkeypress view/onkeypress;
+ onkeydown view/onkeydown;
+ onkeyup view/onkeyup;
+ value view/value;
+ disabled view/disabled;
tabindex view/tabindex;
- disabled view/disabled;
+ onfocus view/onfocus;
+ onblur view/onblur;
+ onchange view/onchange;
readonly view/readonly;
+ alt view/alt;
accesskey view/accesskey;
- maxlength view/maxlength;
- value view/value;
- size view/size" />
+ onselect view/onselect;
+ size view/size;
+ maxlength view/maxlength" />
Modified: z3c.form/trunk/src/z3c/form/browser/textarea.py
===================================================================
--- z3c.form/trunk/src/z3c/form/browser/textarea.py 2007-07-03 02:36:45 UTC (rev 77323)
+++ z3c.form/trunk/src/z3c/form/browser/textarea.py 2007-07-03 05:30:36 UTC (rev 77324)
@@ -21,23 +21,17 @@
import zope.schema.interfaces
from z3c.form import interfaces, widget
+from z3c.form.browser.widget import HTMLTextAreaWidget
-class TextAreaWidget(widget.Widget):
+class TextAreaWidget(HTMLTextAreaWidget, widget.Widget):
"""Textarea widget implementation."""
-
zope.interface.implementsOnly(interfaces.ITextAreaWidget)
css = u'textAreaWidget'
- cols = None
- rows = None
value = u''
- # optional html attributes
- readonly = None
- accesskey = None
-
@zope.component.adapter(zope.schema.interfaces.IField, interfaces.IFormLayer)
@zope.interface.implementer(interfaces.IFieldWidget)
def TextAreaFieldWidget(field, request):
Added: z3c.form/trunk/src/z3c/form/browser/textarea.txt
===================================================================
--- z3c.form/trunk/src/z3c/form/browser/textarea.txt (rev 0)
+++ z3c.form/trunk/src/z3c/form/browser/textarea.txt 2007-07-03 05:30:36 UTC (rev 77324)
@@ -0,0 +1,55 @@
+==============
+TextAreaWidget
+==============
+
+The widget can render a text area field for a text:
+
+ >>> from zope.interface.verify import verifyClass
+ >>> from zope.app.form.interfaces import IInputWidget
+ >>> from z3c.form import interfaces
+ >>> from z3c.form.browser import textarea
+
+The ``TextAreaWidget`` is a widget:
+
+ >>> verifyClass(interfaces.IWidget, textarea.TextAreaWidget)
+ True
+
+The widget can render a input field only by adapting a request:
+
+ >>> from z3c.form.testing import TestRequest
+ >>> request = TestRequest()
+ >>> widget = textarea.TextAreaWidget(request)
+
+Such a field provides IWidget:
+
+ >>> interfaces.IWidget.providedBy(widget)
+ True
+
+We also need to register the template for at least the widget and request:
+
+ >>> import os.path
+ >>> import zope.interface
+ >>> from zope.publisher.interfaces.browser import IDefaultBrowserLayer
+ >>> from zope.pagetemplate.interfaces import IPageTemplate
+ >>> import z3c.form.browser
+ >>> import z3c.form.widget
+ >>> template = os.path.join(os.path.dirname(z3c.form.browser.__file__),
+ ... 'textarea_input.pt')
+ >>> factory = z3c.form.widget.WidgetTemplateFactory(template)
+ >>> zope.component.provideAdapter(factory,
+ ... (zope.interface.Interface, IDefaultBrowserLayer, None, None, None),
+ ... IPageTemplate, name='input')
+
+If we render the widget we get the HTML:
+
+ >>> print widget.render()
+ <textarea class="textAreaWidget"></textarea>
+
+Adding some more attributes to the widget will make it display more:
+
+ >>> widget.id = 'id'
+ >>> widget.name = 'name'
+ >>> widget.value = u'value'
+
+ >>> print widget.render()
+ <textarea id="id" name="name" class="textAreaWidget">value</textarea>
Property changes on: z3c.form/trunk/src/z3c/form/browser/textarea.txt
___________________________________________________________________
Name: svn:eol-style
+ native
Modified: z3c.form/trunk/src/z3c/form/browser/textarea_input.pt
===================================================================
--- z3c.form/trunk/src/z3c/form/browser/textarea_input.pt 2007-07-03 02:36:45 UTC (rev 77323)
+++ z3c.form/trunk/src/z3c/form/browser/textarea_input.pt 2007-07-03 05:30:36 UTC (rev 77324)
@@ -4,10 +4,26 @@
tal:attributes="id view/id;
name view/name;
class view/css;
+ title view/title;
+ lang view/lang;
+ onclick view/onclick;
+ ondblclick view/ondblclick;
+ onmousedown view/onmousedown;
+ onmouseup view/onmouseup;
+ onmouseover view/onmouseover;
+ onmousemove view/onmousemove;
+ onmouseout view/onmouseout;
+ onkeypress view/onkeypress;
+ onkeydown view/onkeydown;
+ onkeyup view/onkeyup;
+ disabled view/disabled;
+ tabindex view/tabindex;
+ onfocus view/onfocus;
+ onblur view/onblur;
+ onchange view/onchange;
cols view/cols;
rows view/rows;
- tabindex view/tabindex;
- disabled view/disabled;
readonly view/readonly;
- accesskey view/accesskey;"
+ accesskey view/accesskey;
+ onselect view/onselect"
tal:content="view/value" />
Added: z3c.form/trunk/src/z3c/form/browser/widget.py
===================================================================
--- z3c.form/trunk/src/z3c/form/browser/widget.py (rev 0)
+++ z3c.form/trunk/src/z3c/form/browser/widget.py 2007-07-03 05:30:36 UTC (rev 77324)
@@ -0,0 +1,82 @@
+##############################################################################
+#
+# Copyright (c) 2007 Zope Foundation and Contributors.
+# All Rights Reserved.
+#
+# This software is subject to the provisions of the Zope Public License,
+# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution.
+# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
+# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
+# FOR A PARTICULAR PURPOSE.
+#
+##############################################################################
+"""Widget Framework Implementation
+
+$Id$
+"""
+__docformat__ = "reStructuredText"
+import zope.interface
+from zope.schema.fieldproperty import FieldProperty
+
+from z3c.form.browser import interfaces
+
+class HTMLFormElement(object):
+ zope.interface.implements(interfaces.IHTMLFormElement)
+
+ id = FieldProperty(interfaces.IHTMLFormElement['id'])
+ css = FieldProperty(interfaces.IHTMLFormElement['css'])
+ style = FieldProperty(interfaces.IHTMLFormElement['style'])
+ title = FieldProperty(interfaces.IHTMLFormElement['title'])
+
+ lang = FieldProperty(interfaces.IHTMLFormElement['lang'])
+
+ onclick = FieldProperty(interfaces.IHTMLFormElement['onclick'])
+ ondblclick = FieldProperty(interfaces.IHTMLFormElement['ondblclick'])
+ onmousedown = FieldProperty(interfaces.IHTMLFormElement['onmousedown'])
+ onmouseup = FieldProperty(interfaces.IHTMLFormElement['onmouseup'])
+ onmouseover = FieldProperty(interfaces.IHTMLFormElement['onmouseover'])
+ onmousemove = FieldProperty(interfaces.IHTMLFormElement['onmousemove'])
+ onmouseout = FieldProperty(interfaces.IHTMLFormElement['onmouseout'])
+ onkeypress = FieldProperty(interfaces.IHTMLFormElement['onkeypress'])
+ onkeydown = FieldProperty(interfaces.IHTMLFormElement['onkeydown'])
+ onkeyup = FieldProperty(interfaces.IHTMLFormElement['onkeyup'])
+
+ disabled = FieldProperty(interfaces.IHTMLFormElement['onkeyup'])
+ tabindex = FieldProperty(interfaces.IHTMLFormElement['onkeyup'])
+ onfocus = FieldProperty(interfaces.IHTMLFormElement['onfocus'])
+ onblur = FieldProperty(interfaces.IHTMLFormElement['onblur'])
+ onchange = FieldProperty(interfaces.IHTMLFormElement['onchange'])
+
+
+class HTMLInputWidget(HTMLFormElement):
+ zope.interface.implements(interfaces.IHTMLInputWidget)
+
+ readonly = FieldProperty(interfaces.IHTMLInputWidget['readonly'])
+ alt = FieldProperty(interfaces.IHTMLInputWidget['alt'])
+ accesskey = FieldProperty(interfaces.IHTMLInputWidget['accesskey'])
+ onselect = FieldProperty(interfaces.IHTMLInputWidget['onselect'])
+
+
+class HTMLTextInputWidget(HTMLInputWidget):
+ zope.interface.implements(interfaces.IHTMLTextInputWidget)
+
+ size = FieldProperty(interfaces.IHTMLTextInputWidget['size'])
+ maxlength = FieldProperty(interfaces.IHTMLTextInputWidget['maxlength'])
+
+
+class HTMLTextAreaWidget(HTMLFormElement):
+ zope.interface.implements(interfaces.IHTMLTextAreaWidget)
+
+ rows = FieldProperty(interfaces.IHTMLTextAreaWidget['rows'])
+ cols = FieldProperty(interfaces.IHTMLTextAreaWidget['cols'])
+ readonly = FieldProperty(interfaces.IHTMLTextAreaWidget['readonly'])
+ accesskey = FieldProperty(interfaces.IHTMLTextAreaWidget['accesskey'])
+ onselect = FieldProperty(interfaces.IHTMLTextAreaWidget['onselect'])
+
+
+class HTMLSelectWidget(HTMLFormElement):
+ zope.interface.implements(interfaces.IHTMLSelectWidget)
+
+ multiple = FieldProperty(interfaces.IHTMLSelectWidget['multiple'])
+ size = FieldProperty(interfaces.IHTMLSelectWidget['size'])
Property changes on: z3c.form/trunk/src/z3c/form/browser/widget.py
___________________________________________________________________
Name: svn:keywords
+ Id
Modified: z3c.form/trunk/src/z3c/form/interfaces.py
===================================================================
--- z3c.form/trunk/src/z3c/form/interfaces.py 2007-07-03 02:36:45 UTC (rev 77323)
+++ z3c.form/trunk/src/z3c/form/interfaces.py 2007-07-03 05:30:36 UTC (rev 77324)
@@ -270,14 +270,11 @@
class IWidget(ILocation):
"""A widget within a form"""
- template = zope.interface.Attribute('''The widget template''')
+ name = zope.schema.BytesLine(
+ title=_('Name'),
+ description=_('The name the widget is known under.'),
+ required=True)
- mode = zope.schema.BytesLine(
- title=_('Mode'),
- description=_('A widget mode.'),
- required=True,
- default=DISPLAY_MODE)
-
label = zope.schema.TextLine(
title=_('Label'),
description=_('''
@@ -290,10 +287,17 @@
'''),
required=True)
+ mode = zope.schema.BytesLine(
+ title=_('Mode'),
+ description=_('A widget mode.'),
+ default=INPUT_MODE,
+ required=True)
+
required = zope.schema.Bool(
title=_('Required'),
description=_('If true the widget should be displayed as required '
'input.'),
+ default=False,
required=True)
error = zope.schema.Field(
@@ -307,6 +311,8 @@
description=_('The value that the widget represents.'),
required=False)
+ template = zope.interface.Attribute('''The widget template''')
+
ignoreRequest = zope.schema.Bool(
title=_('Ignore Request'),
description=_('A flag, when set, forces the widget not to look at '
@@ -352,17 +358,6 @@
class ISelectWidget(ISequenceWidget):
"""Select widget with ITerms option."""
- size = zope.schema.Int(
- title=_('Size'),
- description=_('Determines how many options are shown at once.'),
- default=1)
-
- multiple = zope.schema.Bool(
- title=_('Multiple'),
- description=_('A flag, when set, allows for multiple values to be '
- 'selected.'),
- default=False)
-
prompt = zope.schema.Bool(
title=_('Prompt'),
description=_('A flag, when set, enables a choice explicitely '
Modified: z3c.form/trunk/src/z3c/form/widget.py
===================================================================
--- z3c.form/trunk/src/z3c/form/widget.py 2007-07-03 02:36:45 UTC (rev 77323)
+++ z3c.form/trunk/src/z3c/form/widget.py 2007-07-03 05:30:36 UTC (rev 77324)
@@ -24,6 +24,7 @@
from zope.pagetemplate.interfaces import IPageTemplate
from zope.app.pagetemplate import ViewPageTemplateFile
from zope.i18n import translate
+from zope.schema.fieldproperty import FieldProperty
from z3c.form import interfaces, util, value
from z3c.form.i18n import MessageFactory as _
@@ -44,27 +45,24 @@
zope.interface.implements(interfaces.IWidget)
# widget specific attributes
- label = u''
- mode = interfaces.INPUT_MODE
- required = False
- ignoreRequest = False
- ignoreContext = False
- error = None
+ name = FieldProperty(interfaces.IWidget['name'])
+ label = FieldProperty(interfaces.IWidget['label'])
+ mode = FieldProperty(interfaces.IWidget['mode'])
+ required = FieldProperty(interfaces.IWidget['required'])
+ error = FieldProperty(interfaces.IWidget['error'])
+ value = FieldProperty(interfaces.IWidget['value'])
template = None
- value = None
+ ignoreRequest = FieldProperty(interfaces.IWidget['ignoreRequest'])
- # html element attributes
- id = u''
- name = u''
- title = None
- css = None
- tabindex = None
- disabled = None
+ # The following attributes are for convenience. They are declared in
+ # extensions to the simple widget.
- # this is only for a simpler handling, note that we offer interfaces
- # for the following attributes, See IContextAware, IFormAware, IFieldWidget
+ # See ``interfaces.IContextAware``
context = None
+ ignoreContext = False
+ # See ``interfaces.IFormAware``
form = None
+ # See ``interfaces.IFieldAware``
field = None
# Internal attributes
Modified: z3c.form/trunk/src/z3c/form/widget.txt
===================================================================
--- z3c.form/trunk/src/z3c/form/widget.txt 2007-07-03 02:36:45 UTC (rev 77323)
+++ z3c.form/trunk/src/z3c/form/widget.txt 2007-07-03 05:30:36 UTC (rev 77324)
@@ -152,7 +152,7 @@
widget's properties. Let's create a field first:
>>> ageField = zope.schema.Int(
- ... __name__ = u'age',
+ ... __name__ = 'age',
... title = u'Age',
... min = 0,
... max = 130)
@@ -192,7 +192,7 @@
>>> ageWidget.update()
Traceback (most recent call last):
...
- TypeError: ('Could not adapt', <Widget u'age'>,
+ TypeError: ('Could not adapt', <Widget 'age'>,
<InterfaceClass z3c.form.interfaces.IDataConverter>)
In order for the widget to be able to take the field's default value and use
Modified: z3c.form/trunk/src/z3c/form/zcml.txt
===================================================================
--- z3c.form/trunk/src/z3c/form/zcml.txt 2007-07-03 02:36:45 UTC (rev 77323)
+++ z3c.form/trunk/src/z3c/form/zcml.txt 2007-07-03 05:30:36 UTC (rev 77324)
@@ -76,12 +76,12 @@
Let's use the template within the widget.
>>> print template(myWidget)
- <input type="text" id="" name="" value="" />
+ <input type="text" value="" />
We normly render the widget which returns the registered template.
>>> print myWidget.render()
- <input type="text" id="" name="" value="" />
+ <input type="text" value="" />
If the template does not exist, then the widget directive should fail
immediately:
More information about the Checkins
mailing list