Class
zope.app.form.browser.textwidgets.TextWidget

Text widget.

Single-line text (unicode) input

>>> from zope.publisher.browser import TestRequest
>>> from zope.schema import TextLine
>>> field = TextLine(__name__='foo', title=u'on')
>>> request = TestRequest(form={'field.foo': u'Bob'})
>>> widget = TextWidget(field, request)
>>> widget.hasInput()
True
>>> widget.getInputValue()
u'Bob'
>>> def normalize(s):
...   return '\n  '.join(filter(None, s.split(' ')))
>>> print normalize( widget() )
<input
  class="textType"
  id="field.foo"
  name="field.foo"
  size="20"
  type="text"
  value="Bob"
  />
>>> print normalize( widget.hidden() )
<input
  class="hiddenType"
  id="field.foo"
  name="field.foo"
  type="hidden"
  value="Bob"
  />

Calling setRenderedValue will change what gets output:

>>> widget.setRenderedValue("Barry")
>>> print normalize( widget() )
<input
  class="textType"
  id="field.foo"
  name="field.foo"
  size="20"
  type="text"
  value="Barry"
  />

Check that HTML is correctly encoded and decoded:

>>> request = TestRequest(
...     form={'field.foo': u'<h1>&copy;</h1>'})
>>> widget = TextWidget(field, request)
>>> widget.getInputValue()
u'<h1>&copy;</h1>'
>>> print normalize( widget() )
<input
  class="textType"
  id="field.foo"
  name="field.foo"
  size="20"
  type="text"
  value="&lt;h1&gt;&amp;copy;&lt;/h1&gt;"
  />

Base classes

Implemented Interfaces

Attributes/Properties

Methods

Known Subclasses