Dealing with user input
Once you define a Field on an object, you can re-use it from different Inputs.
Try it out
- Type 'something' into the input below and tab out: notice the validation errors.
- Now, edit it to be valid, or remove it.
class Comment(object): @exposed def fields(self, fields): fields.email_address = EmailField(label='Email address', required=True) class CommentForm(Form): def __init__(self, view): super(CommentForm, self).__init__(view, 'myform') new_comment = Comment() self.use_layout(FormLayout()) self.layout.add_input( TextInput(self, new_comment.fields.email_address) )