Package: zeam.form.base
Summaryzeam.form.baseis a form framework for Zope. It has common goals
and purposes withformliborz3c.formbut tries to:define small sane and reusable components : you don’t
need a full flavored form to render and display only few widgets in
your application,be easily customizable without using hundreds of adapters: most
of settings are set with properties on your form/fields,prevent ZCML declarations by using Grok to register the few needed
adapters (widgets and widgets value extractors),always keep the context untouched: the form works on a content
that can be something else than the context, it can even be a
dictionnary. That means everywhere in the form, including in
widgets, and actions, you can either access the context as the real
context of the form, and have a way to access the content that the
form is working on. This helps greatly if you have complicated
widgets working, including when they are embedded in other widgets
(like in a list or a table),let people easily change form templates, by usingmegrok.pagetemplateby default, selecting which fields goes
where they want,let people define easily their widgets, and use them,be able to create complex forms, like composed or table
forms, where each form can modify the data it needs without having
to hack-o-refresh other sub-forms:allactions are executed before
any widget compute its value to render,By default, it is unware of things like Zope-schema. Generating fields
from a Zope-schema would be done with the help ofzeam.form.ztk.It work with Python 2.6, 2.7 (tested in Zope 2.13 and Grok 1.5). Older
versions works for older versions of Zope 2 and Grok.ExampleLet’s define a quick example. Actions can be defined standalone:from zeam.form.base import Action, SUCCESS

class MailAction(Action):

   def available(self, form):
       return form.context.haveMailHost()

   def __call__(self, form):
       # Send a mail
       form.status = u"Mail sent"
       return SUCCESSAnd included as attributes to the form:class MailForm(Form):
   label = u"Send a mail"
   description = u"to people"
   fields = Fields(Field(u'Name'), Field(u'E-mail'), Field(u'Message'))
   actions = Actions(MailAction(u'Send mail'))(A decoractor can be used on a form method as well if you don’t need
lot of code for your action).For more informationYou can refer to the functional and doctest included in the
package. Since it tries to be composed of small components, there is
many way to put them together.Changelog1.4.1 (2020-08-25)Fixed ‘url’ method as it was faulty. Added tests accordingly.1.4.0 (2020-08-20)Python3.6+ only. Python2 support was dropped.1.3.2 (2019-01-15)Added the defaultFactory handling (needs testing)Updated to newer versions of the GTK packagesSwitch tests to zope.testbrowser.wsgi1.3.1 (2012/11/19)Improve actionshtmlAttributesto reflect fields API.Improve and fixconstrainValuevalidation on fields.1.3 (2012/10/12)Fields now support more options. There is aconstrainValuemethod that can be used in addition tovalidate(to be
compatible withzope.schemafields). An optioninterfacehad
been added as well, and can be used by other zeam.form components to
group fields.Fields can be created with more options given through their
constructor.Fields and widget now support extrahtmlAttributes. They can be
given to the field constructor, and are rendered automatically by
the widget.Actions supportshtmlAttributestoo.Update translations.Add some backward compatiblity helpers.1.2.3 (2012/09/24)grokcore.chameleonis able to negociate i18n by himself. Remove
thei18nLanguageattribute that was an hack.Refactor how the widgets and extractors are created. This is now
done via the form data, and is customizable.1.2.2 (2012/05/02)Update to use the latestgrokcore.componentandgrokcore.view.1.2.1 (2012/04/27)Improve the sorting support on components (fields, actions, widgets).Add adeletemethod to the data manager.Now usegrokcore.chameleoninstead ofmegrok.chameleon.Add the missingstaticto a form default_namespace template.1.2 (2011/11/08)This version no longer support Zope 2 before 2.12.And an helper to know if a field is hidden (so you don’t display the
label).Support a callable to know if a field is required (the callable
takes the form as parameter).Add the HTML 5 attribute required by default in the widgets. Use
novalidate attribute on your form tag if you want to disable it.Improve error reporting. A widget can now return a collection of
error (usefull is the widget is composed of more sub-widgets).Extend API fordataValidatorand widgetprepareRequestValue.Add support for CompoundActions (actions implemented by different
action collections).updateActionsnow return the form on which the action have been
executed. This is usefull in case of sub-forms.1.1 (2011/02/01)zeam.form.basenow uses the latestgrokcore.viewtemplate
grokker.Dependencies have been updated for the latest grokcore and megrok
packages.1.0 (2010/10/19)Translation have been completed and reviewed in Dutch, French and
German.An infrastructure to write generic validatators on all fields have
been added (dataValidatorson aFormData).FieldgetDefaultValueanddefaultValuenow take a
parameter, the form itself. It allows you to compute a default value
that needs the context.Some extraction issues have been fixed: a field which is not
available is no longer extracte and theextractDatamethod can
now be called multiple times with different collection of fields.Some options have been added to Actions: apostOnlyflag that
requires the form to be submitted via thePOSTmethod only, and adescriptionandaccesskeyproperties. ThepostOnlyoption is also available at the form level.Actions return a status flag for the success or the failure.Some helpers have been added to a form:haveRequiredFieldsandhtmlId. Default forms as well have astaticattribute like
Grok views do.Changed the attribute formError to formErrors which now  a list of errors
instead of a single error. Because it’s possible to have more then one
main error in a form (eg. invariants).Changed the formtemplate to display the new formError in an <ul>
<li> structure instead of the … tal:replace … for a single
error.Added thesortandreversemethods on theCollectioncomponent. Tests have been added accordingly.Provided acmpfunction to order components in aCollection. This is now thoroughly tested and demonstrated.1.0rc2 (2010/07/16)The marker to allow extraction affect as well processing them redisplaying
values coming from the request.DataManager API is exported by default.DecoratedAction can be extended. You can provide your own implementation
with thefactoryparameter of the decorator.1.0rc1 (2010/07/05)TheExtractDatamethod has been splitted in two, with the
introduction of thevalidateDatamethod, that allows the form to
override the global form validation process. This lets the
fields validation at the very same place, and only involves
the general form validation process.Created a new marker subclass for the form modes. This marker class
defines a boolean allowing or not the extraction of the affected
component, while the form is processed. Added tests for it.Look for entry pointszeam.form.componentsbefore adapting items
into components in collection. This let you register adapters before
they are used.1.0b4 (2010/06/22)Now the ‘Errors’ class can be used as a logical grouping of ‘Error’
and it stacks, in this case. Added tests to demonstrate and fix the
behavior.1.0b3 (2010/06/04)Fixed the way the identifiers are generated. Now, empty prefixes are
no longer generating malformed ids/names. Added tests to fix that
behavior.1.0b2 (2010/05/13)Fix a bug in FormData initialization.Add a NO_CHANGE marker.1.0b1 (2010/05/03)Initial release