widgets.phonewidget - Phone Widget

A phone number widget.

This widget is an input widget (not made for display forms but for edit and add forms).

It can be used for zope.schema.TextLine fields but has to be requested by the form manually (otherwise the regular TextLine widget will be used for rendering).

If you use the PhoneWidget for rendering regular TextLine attributes (preferably in edit forms or add forms), the phone number is displayed by three input fields representing the international code, the area code and the extension line.

When the entered input is stored with a context object, it is stored as a single unicode string with the numbers divided by single hyphen.

So, input <+12>, <111>, <444> becomes the string '+12-111-444' for the context object.

class waeup.kofa.widgets.phonewidget.PhoneWidget(*args)[source]

Bases: zope.formlib.textwidgets.TextWidget

__doc__ = None
__module__ = 'waeup.kofa.widgets.phonewidget'

Returns current form input.

The value returned must be in a format that can be used as the ‘input’ argument to _toFieldValue.

The default implementation returns the form value that corresponds to the widget’s name. Subclasses may override this method if their form input consists of more than one form element or use an alternative naming convention.


Returns a value suitable for use in an HTML form.

Detects the status of the widget and selects either the input value that came from the request, the value from the _data attribute or the default value.


Check value entered in form further.

Raises ConversionError if values entered contain non-numbers.

For the extension line we silently allow slashes as well.

cssClass = 'phone-input'

A phone widget has input if all three subfields have input.

subwidget_names = ('country', 'area', 'ext')