================
TextLines Widget
================
The text lines widget allows you to store a sequence of textline. This sequence
is stored as a list or tuple. This depends on what you are using as sequence
type.
As for all widgets, the text lines widget must provide the new ``IWidget``
interface:
>>> from zope.interface.verify import verifyClass
>>> from z3c.form import interfaces
>>> from plone.z3cform.textlines import textlines
>>> verifyClass(interfaces.IWidget, textlines.TextLinesWidget)
True
The widget can be instantiated only using the request:
>>> from plone.z3cform.tests import TestRequest
>>> request = TestRequest()
>>> widget = textlines.TextLinesWidget(request)
Before rendering the widget, one has to set the name and id of the widget:
>>> widget.id = 'id'
>>> widget.name = 'name'
We also need to register the template for at least the widget and request:
>>> import zope.component
>>> from zope.pagetemplate.interfaces import IPageTemplate
>>> from z3c.form.testing import getPath
>>> from z3c.form.widget import WidgetTemplateFactory
>>> zope.component.provideAdapter(
... WidgetTemplateFactory(getPath('textlines_input.pt'), 'text/html'),
... (None, None, None, None, textlines.ITextLinesWidget),
... IPageTemplate, name=interfaces.INPUT_MODE)
If we render the widget we get an empty textarea widget:
>>> print widget.render()
Adding some more attributes to the widget will make it display more:
>>> widget.id = 'id'
>>> widget.name = 'name'
>>> widget.value = u'foo\nbar'
>>> print widget.render()