[Checkins] SVN: bluebream/website/docs/v1.0/howto/ one more HOWTO
Baiju M
baiju.m.mail at gmail.com
Tue Jan 26 09:05:34 EST 2010
Log message for revision 108514:
one more HOWTO
Changed:
A bluebream/website/docs/v1.0/howto/dynamicfields.rst
U bluebream/website/docs/v1.0/howto/index.rst
-=-
Added: bluebream/website/docs/v1.0/howto/dynamicfields.rst
===================================================================
--- bluebream/website/docs/v1.0/howto/dynamicfields.rst (rev 0)
+++ bluebream/website/docs/v1.0/howto/dynamicfields.rst 2010-01-26 14:05:33 UTC (rev 108514)
@@ -0,0 +1,40 @@
+Dynamic fields in forms
+=======================
+
+.. warning::
+
+ This documentation is under construction. See the `Documentation
+ Status <http://wiki.zope.org/bluebream/DocumentationStatus>`_ page
+ in wiki for the current status and timeline.
+
+.. based on: http://wiki.zope.org/zope3/HowDoIUseDynamicFieldsInFormlib
+
+To add fields dynamically using ``zope.formlib`` machinery, one
+should avoid subclassing ``form.EditForm``. The ``form.EditForm``
+would require you to also setup an adapter for your form field. The
+following code shows what is involved in having a custom field inside
+your form.
+
+::
+
+ from zope.formlib import form
+ from zope.schema import TextLine
+
+ class TestForm(form.PageForm):
+ my_field_name = 'something'
+
+ def __init__(self, context, request):
+ super(TestForm, self).__init__(context, request)
+ self.form_fields = form.Fields(TextLine(__name__=self.my_field_name,
+ title=u"Test Field"))
+
+ def setUpWidgets(self, ignore_request=False):
+ name = self.name
+ self.widgets = form.setUpWidgets(
+ self.form_fields, self.prefix, self.context, self.request,
+ data={self.my_field_name:SOME_VALUE},
+ ignore_request=ignore_request)
+
+ @form.action(label=_("Submit"))
+ def handleSubmitAction(self, action, data):
+ #do something relevant to you here
Modified: bluebream/website/docs/v1.0/howto/index.rst
===================================================================
--- bluebream/website/docs/v1.0/howto/index.rst 2010-01-26 12:47:55 UTC (rev 108513)
+++ bluebream/website/docs/v1.0/howto/index.rst 2010-01-26 14:05:33 UTC (rev 108514)
@@ -16,3 +16,4 @@
defaultview
newdependency
absoluteurl
+ dynamicfields
More information about the checkins
mailing list