Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
janwijbrand committed Jan 6, 2009
1 parent 5868035 commit 4841aaa
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 3 deletions.
3 changes: 2 additions & 1 deletion CHANGES.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ Changes
1.1 (unreleased)
----------------

* ...
* Have GrokForm define an empty actions attribute by default, in order
for "action-less" forms to work easily.

1.0 (2008-09-25)
----------------
Expand Down
2 changes: 2 additions & 0 deletions src/grokcore/formlib/components.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ class GrokForm(object):
'renaming' zope.formlib's update() to update_form() and by
disallowing subclasses to have custom render() methods."""

actions = form.Actions()

def update(self):
"""Subclasses can override this method just like on regular
grok.Views. It will be called before any form processing
Expand Down
16 changes: 14 additions & 2 deletions src/grokcore/formlib/ftests/form/actions.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,14 @@
>>> browser.getControl("Meet").click()
>>> print browser.contents
Manfred the Second meets Ellie
There used to be a bug (or rather an inconvenience) where when no actions were
defined, the template used for rendering a Form component would fail expecting
to find an actions attribute on the component. This is fixed now and thus the
following view does not raise an AttributeError anymore::
>>> browser.open("http://localhost/manfred/greet")
"""
import grokcore.formlib as grok
from zope import schema
Expand All @@ -57,8 +65,8 @@ class Mammoth(grok.testing.Model):
grok.testing.protect_get(grok.Public, 'name', 'size')
grok.testing.protect_set(grok.Public, 'name', 'size')

name = FieldProperty(IMammoth['name'])
size = FieldProperty(IMammoth['size'])
name = FieldProperty(IMammoth['name'])
size = FieldProperty(IMammoth['size'])

class Edit(grok.EditForm):
@grok.action("Apply")
Expand All @@ -81,3 +89,7 @@ class Meet(grok.Form):
@grok.action('Meet')
def meet(self, other):
return self.context.name + ' meets ' + other

class Greet(grok.Form):
form_fields = grok.Fields(
other = schema.TextLine(title=u'Mammoth to say hi to'))

0 comments on commit 4841aaa

Please sign in to comment.