Skip to main content

A widget package for Dexterity projects.

Project description

Life, the Universe, and Everything

A widget package for Dexterity projects.

collective.z3cform.widgets provides the following widgets:

EnhancedTextLinesFieldWidget

This widget is an ajaxified version of the TextLinesFieldWidget that will allow creation, sort, update and deletion of text lines; degrades to <textarea> if JavaScript is not enabled.

https://github.com/collective/collective.z3cform.widgets/raw/master/enhancedtextlines.png

This widget uses the jQuery TaskPlease plugin.

TokenInputFieldWidget

TokenInputFieldWidget allows your users to select multiple items from a predefined list, using autocompletion as they type to find each item. You may have seen a similar type of text entry when filling in the recipients field sending messages on Facebook. This widget will degrade to <textarea> if JavaScript is not enabled.

https://github.com/collective/collective.z3cform.widgets/raw/master/tokeninput.png

This widget uses the jQuery Tokeninput plugin.

MultiContentSearchFieldWidget

A widget to add a dynamic list of objects. This works as a widget for related items field so it must be used like this:

relatedItems = RelationList(
    title=_(u'label_related_items', default=u'Related Items'),
    default=[],
    value_type=RelationChoice(title=u"Related",
                  source=ObjPathSourceBinder(portal_type='Document')),
    required=False,
    )
form.widget(relatedItems=MultiContentSearchFieldWidget)

The parameters passed to the ObjPathSourceBinder class are used to filter the search of elements to relate to. If no parameters are passed, a tree structure is shown in the widget.

SimpleRichTextWidget

A lightweight and unbloated Rich Text Editor (RTE / WYSIWYG). These parameters can be configured:

'iframe_height': height in pixels,
'format_block': 'true' or 'false',
'bold': 'true' or 'false',
'italic': 'true' or 'false',
'unordered_list': 'true' or 'false',
'link': 'true' or 'false',
'image': 'true' or 'false',
'allow_disable': 'true' or 'false'

This widget uses the jQuery RTE plugin.

Don’t Panic

New fields

EnhancedTextLinesFieldWidget

To use this widget we must use a List field or a Tuple field with the value_type as an schema.TextLine() like this:

from collective.z3cform.widgets.enhancedtextlines import EnhancedTextLinesFieldWidget

form.widget(options = EnhancedTextLinesFieldWidget)
options = schema.Tuple(
    title=_(u"Options"),
    value_type=schema.TextLine(),
    missing_value=(),
    )
TokenInputFieldWidget

To use this Widget we must use a List field or a Tuple field with the value_type as a schema.TextLine() like this:

from collective.z3cform.widgets.token_input_widget import TokenInputFieldWidget

form.widget(subjects=TokenInputFieldWidget)
subjects = schema.List(
    title=_(u"Categories"),
    value_type=schema.TextLine(),
    default=[],
    )
MultiContentSearchFieldWidget

The parameters passed to the ObjPathSourceBinder class are used to filter the search of elements to relate to.. if none parameter are passed, a tree structure is shown in the widget:

from collective.z3cform.widgets.multicontent_search_widget import MultiContentSearchFieldWidget

form.widget(relatedItems=MultiContentSearchFieldWidget)
relatedItems = RelationList(
    title=_(u"Related Items"),
    default=[],
    value_type=RelationChoice(title=u"Related",
        source=ObjPathSourceBinder(portal_type='Document')),
    )
SimpleRichTextWidget

TBA

Override existing fields

EnhancedTextLinesFieldWidget

TBA

TokenInputFieldWidget

To override an existing field put the following code in the __init__.py of your package:

from plone.autoform.interfaces import WIDGETS_KEY
from plone.directives.form.schema import TEMP_KEY
from plone.app.dexterity.behaviors.metadata import ICategorization
from zope import schema as _schema

_directives_values = ICategorization.queryTaggedValue(TEMP_KEY)
_directives_values.setdefault(WIDGETS_KEY, {})
widget = 'collective.z3cform.widgets.token_input_widget.TokenInputFieldWidget'
_directives_values[WIDGETS_KEY]['subjects'] = widget
_schema.getFields(ICategorization)['subjects'].index_name = 'Categories'
MultiContentSearchFieldWidget

TBA

SimpleRichTextWidget

TBA

Future widgets

The following widgets will be available in this package in the near future:

  • widget to select an option from a list; this widget will degrade to <select> if JavaScript is not enabled.

  • widget to select multiple options from a list; this widget will degrade to <select> if JavaScript is not enabled.

This widgets will probably use the Chosen plugin.

Browsers supported

All modern browsers should be supported (Mozilla Firefox 3.0+, Google Chrome 7.0+, Apple Safari 4.0+, Opera 10.0+ and Microsoft Internet Explorer 9.0+).

Mostly Harmless

https://secure.travis-ci.org/collective/collective.z3cform.widgets.png

Got an idea? Found a bug? Let us know by opening a support ticket.

See also

More widgets you might like:

Installation

To enable this product in a buildout-based installation:

  1. Edit your buildout.cfg and add collective.z3cform.widgets to the list of eggs to install:

    [buildout]
    ...
    eggs =
        collective.z3cform.widgets
  2. If you are using Plone 4.1 you may need to extend a Dexterity known good set (KGS) to make sure that you get the right versions of the packages that make up Dexterity:

    [buildout]
    ...
    extends =
        http://good-py.appspot.com/release/dexterity/1.2.1

After updating the configuration you need to run ‘’bin/buildout’’, which will take care of updating your system.

Share and Enjoy

collective.z3cform.widgets would not have been possible without the contribution of the following people:

  • Franco Pellegrini

  • Gonzalo Almeida

  • Silvestre Huens

  • Héctor Velarde

  • Cleber J. Santos

  • João S. O. Bueno

Development sponsored by OpenMultimedia.

Changelog

Because you have to know where your towel is.

1.0b5 (2013-03-25)

  • Remove dependency on zope.i18n as it is causing ConfigurationConflictError (issue #28). [hvelarde]

1.0b4 (2013-03-23)

  • Fix package dependencies to be Plone 4.3 compatible. [hvelarde]

  • Fix the rendered URLs of related items in the MultiContentSearchWidget in display_mode to be actual URLs, not the physical path inside Zope. [leorochael]

1.0b3 (2013-01-14)

  • Refactoring of the SimpleRichTextWidget to make it work in an AJAX call. [quimera]

  • Do not mix unicode and strings in TokenInputWiget editing (fixes #20). [jsbueno]

  • Checking if contenttree js code should be run or not. [Flecox]

  • Test compatibility with Plone 4.3. [hvelarde]

  • Add Pillow as a dependency of the package. [hvelarde]

  • Import ViewPageTemplateFile from zope.browserpage to avoid dependency on zope.app.pagetemplate. [hvelarde]

1.0b2 (2012-09-27)

  • New field and widget included which uses the rte-light editor [frapell]

1.0b1 (2012-09-16)

  • Added Dutch translation. [kingel]

  • Correction in tasks layout. [quimera]

  • Spinners for the related widget so you know is working. [frapell]

1.0a4 (2012-09-04)

  • Spanish translation was updated; Brazilian Portuguese translation was added. [hvelarde]

  • Resources are only loaded for logged in users. [quimera]

  • Ordered search catalog in MultiContentSearchFieldWidget. [flecox]

  • Infinite Scroll in MultiContentSearchFieldWidget (fixes #10). [flecox]

  • Fix bug when searching with no results in MultiContentSearchFieldWidget. [flecox]

  • Updating taskplease library in EnhancedTextLinesFieldWidget (fixes #13). [flecox]

1.0a3 (2012-06-15)

  • Updated package documentation. [hvelarde]

  • Fixing style in EnhancedTextLinesFieldWidget and TokenInputFieldWidget. [flecox]

  • TasksWidget was renamed to EnhancedTextLinesFieldWidget (fixes #7). [hvelarde]

  • Changing the name of RelatedContentWidget to MultiContentSearchFieldWidget. [flecox]

1.0a2 (2012-05-18)

  • Updated package documentation. [hvelarde]

  • Changing the name of KeywordWidget to a better name TokenInputFieldWidget. [flecox]

  • Now you can add a token just by pressing Enter. [flecox]

1.0a1 (2012-05-04)

  • Initial release.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

collective.z3cform.widgets-1.0b5.zip (106.7 kB view details)

Uploaded Source

File details

Details for the file collective.z3cform.widgets-1.0b5.zip.

File metadata

File hashes

Hashes for collective.z3cform.widgets-1.0b5.zip
Algorithm Hash digest
SHA256 ec1367b6a3035f20aac45569fe8cc0034fd05790a244c94564baad82612decb3
MD5 4696293dbb93e7fd5ab6f504bd1c6484
BLAKE2b-256 e047a4c3d351282c4df1d564717aa8ebb2cbaa1085b0a74ab72381bc037aae30

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page