Layout
======

plone.z3cform tries to avoid mixing Acqusition into your forms.  Also,
it tries to separate form templates from layout templates (aka main
template), so that your forms are usable in different contexts,
e.g. in portlets.

Using schemas is one way of defining the fields in a form:

  >>> from zope import interface, schema
  >>> from z3c.form import form, field

  >>> class MySchema(interface.Interface):
  ...     age = schema.Int(title=u"Age", description=u"Enter your age")
  >>> class MyForm(form.Form):
  ...     ignoreContext = True
  ...     fields = field.Fields(MySchema)

Note that no Plone chickens were harmed in the implementation of the
form.  The only Plone specific part comes now, where we wrap the form
into a Plone layout and register it:

  >>> from plone.app.z3cform.layout import wrap_form
  >>> MyWrappedForm = wrap_form(MyForm)

``MyWrappedForm`` is the class that you can register as your view.

Let's try to render it:

  >>> print MyWrappedForm(None, None)()
  Traceback (most recent call last):
  TraversalError: (None, 'main_template')

Hardly a surprise that there's no way to get to 'main_template' from
None.  Let's try something more realistic:

  >>> view = MyWrappedForm(portal, portal.REQUEST).__of__(portal)
  >>> html = view()
  >>> print html # doctest: +ELLIPSIS
  <...You are here:...Enter your age...>

Let's make sure that we're rendering the Plone macros here.  Only
these have a CSS class "horizontal":

  >>> 'class="horizontal"' in html
  True
