[Checkins] SVN: plone.z3cform/branches/nathan-sub-form-factory-and-css/plone/z3cform/crud/ made the appropriate changes to add edit sub form factory and use css class listing in the crud table so it looks like standard plone

Nathan Van Gheem vangheem at gmail.com
Wed Oct 15 13:34:36 EDT 2008


Log message for revision 92252:
  made the appropriate changes to add edit sub form factory and use css class listing in the crud table so it looks like standard plone

Changed:
  U   plone.z3cform/branches/nathan-sub-form-factory-and-css/plone/z3cform/crud/README.txt
  U   plone.z3cform/branches/nathan-sub-form-factory-and-css/plone/z3cform/crud/crud-table.pt
  U   plone.z3cform/branches/nathan-sub-form-factory-and-css/plone/z3cform/crud/crud.py

-=-
Modified: plone.z3cform/branches/nathan-sub-form-factory-and-css/plone/z3cform/crud/README.txt
===================================================================
--- plone.z3cform/branches/nathan-sub-form-factory-and-css/plone/z3cform/crud/README.txt	2008-10-15 17:31:31 UTC (rev 92251)
+++ plone.z3cform/branches/nathan-sub-form-factory-and-css/plone/z3cform/crud/README.txt	2008-10-15 17:34:36 UTC (rev 92252)
@@ -423,6 +423,41 @@
   >>> 'Thomas' in storage
   True
 
+Customizing sub forms
+---------------------
+
+The EditForm class allows you to specify an editsubform_factory-a classs 
+inherits from EditSubForm.  This allows you to say, override the crud-row.pt
+page template and customize the look of the fields.
+
+  >>> import zope.schema
+  >>> class MyCustomEditSubForm(crud.EditSubForm):
+  ...
+  ...     def _select_field(self):
+  ...         """I want to customize the field that it comes with..."""
+  ...         select_field = field.Field(
+  ...         zope.schema.TextLine(__name__='select',
+  ...                              required=False,
+  ...                              title=u'select'))
+  ...         return select_field
+
+  >>> class MyCustomEditForm(MyEditForm):
+  ...     editsubform_factory = MyCustomEditSubForm
+
+  >>> class MyCustomFormWithCustomSubForm(MyCustomForm):
+  ...     editform_factory = MyCustomEditForm
+
+  >>> request = TestRequest()
+  >>> html = MyCustomFormWithCustomSubForm(None, TestRequest())()
+
+Still uses same form as before
+  >>> "Delete" in html, "Apply changes" in html, "Capitalize" in html
+  (False, False, True)
+
+Just changes the widget used for selecting...
+  >>> 'type="checkbox"' in html
+  False
+
 Using batching
 --------------
 

Modified: plone.z3cform/branches/nathan-sub-form-factory-and-css/plone/z3cform/crud/crud-table.pt
===================================================================
--- plone.z3cform/branches/nathan-sub-form-factory-and-css/plone/z3cform/crud/crud-table.pt	2008-10-15 17:31:31 UTC (rev 92251)
+++ plone.z3cform/branches/nathan-sub-form-factory-and-css/plone/z3cform/crud/crud-table.pt	2008-10-15 17:34:36 UTC (rev 92252)
@@ -1,4 +1,4 @@
-<html xmlns="http://www.w3.org/1999/xhtml"
+ <html xmlns="http://www.w3.org/1999/xhtml"
       xmlns:metal="http://xml.zope.org/namespaces/metal"
       xmlns:tal="http://xml.zope.org/namespaces/tal"
       xmlns:i18n="http://xml.zope.org/namespaces/i18n"
@@ -25,7 +25,7 @@
                            value python:batch.number-1"
            />
 
-    <table class="crud-table" tal:define="rows view/subforms">
+    <table class="listing" tal:define="rows view/subforms">
         <thead tal:define="row1 python:len(rows) and rows[0] or None"
                tal:condition="python:row1 is not None">
           <tr>

Modified: plone.z3cform/branches/nathan-sub-form-factory-and-css/plone/z3cform/crud/crud.py
===================================================================
--- plone.z3cform/branches/nathan-sub-form-factory-and-css/plone/z3cform/crud/crud.py	2008-10-15 17:31:31 UTC (rev 92251)
+++ plone.z3cform/branches/nathan-sub-form-factory-and-css/plone/z3cform/crud/crud.py	2008-10-15 17:34:36 UTC (rev 92252)
@@ -218,6 +218,9 @@
 class EditForm(form.Form):
     label = _(u"Edit")
     template = viewpagetemplatefile.ViewPageTemplateFile('crud-table.pt')
+    
+    #exposes the edit sub form for your own derivatives
+    editsubform_factory = EditSubForm
 
     @property
     def prefix(self):
@@ -231,7 +234,7 @@
     def _update_subforms(self):
         self.subforms = []
         for id, item in self.batch:
-            subform = EditSubForm(self, self.request)
+            subform = self.editsubform_factory(self, self.request)
             subform.content = item
             subform.content_id = id
             subform.update()



More information about the Checkins mailing list