You are here: Home Plone products plone.app.z3cform

plone.app.z3cform (0.4.5)

1
by Olha Pelishok last modified 2009-06-11
0.0
0.0
0.0
0.0
Released on 2009-06-25 by Plone Foundation for Plone 3.0 under GPL - GNU General Public License available for All platforms.
Software development stage: stable
A collection of widgets, templates and other components for use with z3c.form and Plone

A collection of widgets and templates, and other components for use with `z3c.form`_ in Plone_.  This is much related to `plone.z3cform`_,
the library that enables Zope 2 applications to use z3c.form.
.. _z3c.form: http://pypi.python.org/pypi/z3c.form
.. _Plone: http://plone.org
.. _plone.z3cform: http://pypi.python.org/pypi/plone.z3cform

WYSIWYG widget

The ``wysiwyg`` package provides an implementation of the Plone WYSIWYG widget compatible with ``z3c.form``.  This will allow you to
use Kupu, FCKeditor and other editors compatible with the Plone WYSIWYG interface in your ``z3c.form`` forms.

To use, simply set the widget factory for the widget you'd like to be displayed with the WYSIWYG widget:

  >>> from zope import interface, schema
  >>> from z3c.form import form, field
  >>> from z3c.form.interfaces import INPUT_MODE
  >>> from plone.app.z3cform.wysiwyg.widget import WysiwygFieldWidget

  >>> class IProfile(interface.Interface):
  ...     name = schema.TextLine(title=u"Name")
  ...     age = schema.Int(title=u"Age")
  ...     bio = schema.Text(title=u"Bio")

  >>> class MyForm(form.Form):
  ...     fields = field.Fields(IProfile)
  ...     fields['bio'].widgetFactory[INPUT_MODE] = WysiwygFieldWidget

Query select widget

The ``queryselect`` module provides a query source compatible with ``z3c.formwidget.query`` which combines to a selection field that can
be queried.

The native value type for the widget is Archetypes UID collections. The default implementation will simply search using the
``SearchableText`` index in the portal catalog. 

This is how your form schema could look like:

  >>> from zope import interface, schema
  >>> from plone.app.z3cform.queryselect import ArchetypesContentSourceBinder

  >>> class ISelection(interface.Interface):
  ...     items = schema.Set(
  ...         title=u"Selection",
  ...         description=u"Search for content",
  ...         value_type=schema.Choice(
  ...             source=ArchetypesContentSourceBinder()))

Optionally, instead of storing Archetypes UIDs, you can choose to use ``persistent.wref``, i.e. weak references, instead of UIDs:

  >>> from plone.app.z3cform.queryselect import uid2wref
  >>> factory = uid2wref(ISelection['items'])

To store weak references instead of UIDs you would register such a factory as a component adapting the context.  The factory
automatically provides the interface which defines the field.



Document Actions
Powered by Plone