@view_config(renderer="templates/form.pt", name="readonly_argument")
@demonstrate("Readonly Widget Argument")
def readonly_argument(self):
import datetime
class Schema(colander.Schema):
textinput = colander.SchemaNode(
colander.String(),
widget=deform.widget.TextInputWidget(readonly=True),
missing=colander.null,
description="Text in a text input",
)
textarea = colander.SchemaNode(
colander.String(),
widget=deform.widget.TextAreaWidget(readonly=True),
missing=colander.null,
description="Text in a textarea",
)
single_select = colander.SchemaNode(
colander.String(),
widget=deform.widget.SelectWidget(
values=[("a", "The letter a"), ("b", "The letter b")],
readonly=True,
),
missing=colander.null,
description="A letter",
)
multi_select = colander.SchemaNode(
colander.String(),
widget=deform.widget.SelectWidget(
values=[("a", "The letter a"), ("b", "The letter b")],
multiple=True,
readonly=True,
),
missing=colander.null,
description="Some letters",
)
richtext = colander.SchemaNode(
colander.String(),
widget=deform.widget.RichTextWidget(readonly=True),
description="Some text",
missing=colander.null,
)
money = colander.SchemaNode(
colander.Decimal(),
widget=deform.widget.MoneyInputWidget(readonly=True),
description="Some money",
missing=colander.null,
)
date = colander.SchemaNode(
colander.Date(),
widget=deform.widget.DateInputWidget(readonly=True),
description="Some date",
missing=colander.null,
)
appstruct = {
"textinput": "readonly text input",
"textarea": "readonly text area",
"single_select": "a",
"multi_select": ("a", "b"),
"richtext": "<p>Yo!</p>",
"money": decimal.Decimal(1),
"date": datetime.date(2010, 5, 5),
}
schema = Schema()
form = deform.Form(schema, buttons=("submit",))
return self.render_form(form, appstruct=appstruct)