[Checkins] SVN: z3ext.layoutform/trunk/ Widget pagelet for different widget modes added
Nikolay Kim
fafhrd91 at gmail.com
Tue Jun 16 02:46:29 EDT 2009
Log message for revision 101031:
Widget pagelet for different widget modes added
Changed:
U z3ext.layoutform/trunk/CHANGES.txt
U z3ext.layoutform/trunk/src/z3ext/layoutform/browser/configure.zcml
U z3ext.layoutform/trunk/src/z3ext/layoutform/browser/widget.py
D z3ext.layoutform/trunk/src/z3ext/layoutform/browser/widgetDisplay.pt
A z3ext.layoutform/trunk/src/z3ext/layoutform/browser/widget_display.pt
U z3ext.layoutform/trunk/src/z3ext/layoutform/form.py
U z3ext.layoutform/trunk/src/z3ext/layoutform/tests/tests.txt
-=-
Modified: z3ext.layoutform/trunk/CHANGES.txt
===================================================================
--- z3ext.layoutform/trunk/CHANGES.txt 2009-06-16 06:41:17 UTC (rev 101030)
+++ z3ext.layoutform/trunk/CHANGES.txt 2009-06-16 06:46:29 UTC (rev 101031)
@@ -2,7 +2,12 @@
CHANGES
=======
+1.4.1 (Unreleased)
+------------------
+- Widget pagelet for different widget modes added
+
+
1.4.0 (2009-05-22)
------------------
Modified: z3ext.layoutform/trunk/src/z3ext/layoutform/browser/configure.zcml
===================================================================
--- z3ext.layoutform/trunk/src/z3ext/layoutform/browser/configure.zcml 2009-06-16 06:41:17 UTC (rev 101030)
+++ z3ext.layoutform/trunk/src/z3ext/layoutform/browser/configure.zcml 2009-06-16 06:46:29 UTC (rev 101031)
@@ -1,4 +1,4 @@
-<configure
+<configure
xmlns="http://namespaces.zope.org/zope"
xmlns:z3ext="http://namespaces.zope.org/z3ext">
@@ -10,8 +10,8 @@
permission="zope.Public"
interface="z3c.form.interfaces.ITextAreaWidget" />
</class>
-
- <adapter
+
+ <adapter
for="zope.schema.interfaces.IText
..interfaces.ILayoutFormLayer"
factory=".textarea.TextAreaFieldWidget" />
@@ -108,13 +108,37 @@
interface="z3ext.layoutform.browser.interfaces.IWidget" />
<z3ext:pagelet
+ type="form.widget"
for="z3c.form.interfaces.IWidget
zope.schema.interfaces.IField
z3c.form.interfaces.IForm"
- template="widget.pt"
- type="form.widget" />
+ class=".widget.WidgetRenderer" />
- <adapter
+ <z3ext:pagelet
+ name="input"
+ type="form.widget"
+ for="z3c.form.interfaces.IWidget
+ zope.schema.interfaces.IField
+ z3c.form.interfaces.IForm"
+ template="widget.pt" />
+
+ <z3ext:pagelet
+ name="hidden"
+ type="form.widget"
+ for="z3c.form.interfaces.IWidget
+ zope.schema.interfaces.IField
+ z3c.form.interfaces.IForm"
+ template="widget_hidden.pt" />
+
+ <z3ext:pagelet
+ name="display"
+ type="form.widget"
+ for="z3c.form.interfaces.IWidget
+ zope.schema.interfaces.IField
+ z3c.form.interfaces.IForm"
+ template="widget_display.pt" />
+
+ <adapter
name="form.widget"
factory=".widget.getWidgetManager" />
@@ -123,7 +147,7 @@
for="z3c.form.interfaces.IWidget
zope.schema.interfaces.IField
z3c.form.interfaces.IDisplayForm"
- template="widgetDisplay.pt"
+ template="widget_display.pt"
type="form.widget" />
<!-- add form buttons -->
@@ -138,11 +162,11 @@
name="z3ext-layoutform.css"
library="z3ext" type="stylesheet"
file="styles.css" filetype="zrt" />
-
+
<z3ext:resource
file="required.gif"
name="z3ext-layoutform-required.gif" />
-
+
<z3ext:resource
file="linkOpaque.gif"
name="z3ext-layoutform-linkOpaque.gif" />
Modified: z3ext.layoutform/trunk/src/z3ext/layoutform/browser/widget.py
===================================================================
--- z3ext.layoutform/trunk/src/z3ext/layoutform/browser/widget.py 2009-06-16 06:41:17 UTC (rev 101030)
+++ z3ext.layoutform/trunk/src/z3ext/layoutform/browser/widget.py 2009-06-16 06:46:29 UTC (rev 101031)
@@ -11,15 +11,29 @@
# FOR A PARTICULAR PURPOSE.
#
##############################################################################
-"""
+"""
$Id: 2007-12-12 12:27:02Z fafhrd $
"""
from zope import interface, component
+from zope.component import getMultiAdapter
from z3c.form.interfaces import IWidget
from z3ext.layout.interfaces import IPageletContext
+import interfaces
+
+class WidgetRenderer(object):
+
+ def render(self):
+ renderer = getMultiAdapter(
+ (self.context,) + self.contexts + (self.request,),
+ interfaces.IWidget, name=self.context.mode)
+
+ renderer.update()
+ return renderer.render()
+
+
@component.adapter(IWidget)
@interface.implementer(IPageletContext)
def getWidgetManager(widget):
Deleted: z3ext.layoutform/trunk/src/z3ext/layoutform/browser/widgetDisplay.pt
===================================================================
--- z3ext.layoutform/trunk/src/z3ext/layoutform/browser/widgetDisplay.pt 2009-06-16 06:41:17 UTC (rev 101030)
+++ z3ext.layoutform/trunk/src/z3ext/layoutform/browser/widgetDisplay.pt 2009-06-16 06:46:29 UTC (rev 101031)
@@ -1,8 +0,0 @@
-<div class="z-form-field">
- <label tal:attributes="for context/id;
- title context/field/description"
- tal:content="context/label">The Label</label>
- <div tal:content="structure context/render">
- <input type="text" style="width:100%" />
- </div>
-</div>
Copied: z3ext.layoutform/trunk/src/z3ext/layoutform/browser/widget_display.pt (from rev 101029, z3ext.layoutform/trunk/src/z3ext/layoutform/browser/widgetDisplay.pt)
===================================================================
--- z3ext.layoutform/trunk/src/z3ext/layoutform/browser/widget_display.pt (rev 0)
+++ z3ext.layoutform/trunk/src/z3ext/layoutform/browser/widget_display.pt 2009-06-16 06:46:29 UTC (rev 101031)
@@ -0,0 +1,8 @@
+<div class="z-form-field">
+ <label tal:attributes="for context/id;
+ title context/field/description"
+ tal:content="context/label">The Label</label>
+ <div tal:content="structure context/render">
+ <input type="text" style="width:100%" />
+ </div>
+</div>
Modified: z3ext.layoutform/trunk/src/z3ext/layoutform/form.py
===================================================================
--- z3ext.layoutform/trunk/src/z3ext/layoutform/form.py 2009-06-16 06:41:17 UTC (rev 101030)
+++ z3ext.layoutform/trunk/src/z3ext/layoutform/form.py 2009-06-16 06:46:29 UTC (rev 101031)
@@ -47,6 +47,7 @@
def __iter__(self):
return iter(self._data_values)
+
class PageletBaseForm(form.BaseForm, BrowserPagelet):
__call__ = BrowserPagelet.__call__
Modified: z3ext.layoutform/trunk/src/z3ext/layoutform/tests/tests.txt
===================================================================
--- z3ext.layoutform/trunk/src/z3ext/layoutform/tests/tests.txt 2009-06-16 06:41:17 UTC (rev 101030)
+++ z3ext.layoutform/trunk/src/z3ext/layoutform/tests/tests.txt 2009-06-16 06:46:29 UTC (rev 101031)
@@ -22,7 +22,7 @@
... min=0,
... default=20,
... required=False)
- ...
+ ...
... @interface.invariant
... def startEndDates(person):
... if person.age < 20:
@@ -103,7 +103,7 @@
<div class="z-form-field">
<label for="add_input_name">Content short name</label>
<div class="z-form-help">
- Should not contain spaces, underscores or mixed case.
+ Should not contain spaces, underscores or mixed case.
Short Name is part of the item's web address.
</div>
<div>
@@ -123,3 +123,54 @@
</div>
</form>
</div>
+
+We have different renderer for hidden widgets
+
+ >>> from z3c.form.interfaces import HIDDEN_MODE
+ >>> addForm.fields['age'].mode = HIDDEN_MODE
+
+ >>> addForm.update()
+ >>> print addForm.render()
+ <div class="z-form z-form-add"><form action="http://127.0.0.1" method="post"
+ enctype="multipart/form-data" name="form" id="form">
+ <div class="z-form-fieldset">
+ <div class="z-form-field">
+ <label for="form-widgets-name" title="">Name</label>
+ <span class="z-form-fieldRequired"> </span>
+ <div class="z-form-help"></div>
+ <div><input type="text" id="form-widgets-name"
+ name="form.widgets.name"
+ class="text-widget required textline-field" value="" />
+ </div>
+ </div>
+ <label style="display: none;" for="form-widgets-age"
+ title="The person's age.">Age</label>
+ <input type="hidden" id="form-widgets-age"
+ name="form.widgets.age" class="hidden-widget"
+ value="20" />
+ </div>
+ <div class="z-form-controls">
+ <hr />
+ <div class="z-form-field">
+ <label for="add_input_name">Content short name</label>
+ <div class="z-form-help">
+ Should not contain spaces, underscores or mixed case.
+ Short Name is part of the item's web address.
+ </div>
+ <div>
+ <input type="text" name="add_input_name"
+ id="add_input_name" />
+ </div>
+ </div>
+ <span>
+ <input type="submit" id="form-buttons-add"
+ name="form.buttons.add"
+ class="z-form-addbutton button-field" value="Add" />
+ <input type="submit" id="form-buttons-cancel"
+ name="form.buttons.cancel"
+ class="z-form-cancelbutton button-field"
+ value="Cancel" />
+ </span>
+ </div>
+ </form>
+ </div>
More information about the Checkins
mailing list