Пример #1
0
    def __init__(self, view):
        super(CommentForm, self).__init__(view, 'myform')

        new_comment = Comment()
        grouped_inputs = FieldSet(
            view, legend_text='Leave a comment').use_layout(FormLayout())
        self.add_child(grouped_inputs)

        grouped_inputs.layout.add_input(
            TextInput(self, new_comment.fields.email_address))
        grouped_inputs.layout.add_input(
            TextInput(self, new_comment.fields.text))

        self.define_event_handler(new_comment.events.submit)
        grouped_inputs.add_child(ButtonInput(self, new_comment.events.submit))
Пример #2
0
    def __init__(self, view, address):
        super(EditAddressForm, self).__init__(view, 'edit_form')

        grouped_inputs = FieldSet(view, legend_text='Edit address')
        grouped_inputs.use_layout(FormLayout())
        grouped_inputs.layout.add_input(TextInput(self, address.fields.name))
        grouped_inputs.layout.add_input(
            TextInput(self, address.fields.email_address))
        self.add_child(grouped_inputs)

        btn = grouped_inputs.add_child(ButtonInput(self,
                                                   address.events.update))
        btn.use_layout(ButtonLayout(style='primary'))
Пример #3
0
    def __init__(self, view):
        super(AddAddressForm, self).__init__(view, 'add_form')

        new_address = Address()
        grouped_inputs = FieldSet(view, legend_text='Add an address')
        grouped_inputs.use_layout(FormLayout())
        grouped_inputs.layout.add_input(
            TextInput(self, new_address.fields.name))
        grouped_inputs.layout.add_input(
            TextInput(self, new_address.fields.email_address))
        self.add_child(grouped_inputs)

        btn = grouped_inputs.add_child(
            ButtonInput(self, new_address.events.save))
        btn.use_layout(ButtonLayout(style='primary'))