I'm trying to use deform as part of pyramid and have no trouble getting fully editable or fully read-only forms, but I can't seem to find a way of creating a read-only text input field. The following code does not do what I want, but I think you should be able to see what I'm trying to do:
class UserSchema(colander.MappingSchema):
first_name = colander.SchemaNode(colander.String())
last_name = colander.SchemaNode(colander.String())
username = colander.SchemaNode(colander.String())
password = colander.SchemaNode(colander.String())
email = colander.SchemaNode(colander.String(), validator=colander.Email())
organization_name = colander.SchemaNode(colander.String(), widget=deform.widget.TextInputWidget(readonly=True))
Use the readonly template:
organization_name = colander.SchemaNode(colander.String(), missing='', widget=deform.widget.TextInputWidget(template='readonly/textinput'))
You have to define a missing value, otherwise the validation fails.
Deform version 0.9.6+:
Deform has been updated since and the readonly keyword argument should work as expected.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With