示例#1
0
    def __init__(self, view, comment):
        super().__init__(view, 'myform')
        self.use_layout(FormLayout())

        self.layout.add_input(TextInput(self, comment.fields.email_address))
        self.layout.add_input(TextInput(self, comment.fields.text))
        self.add_child(ButtonInput(self, comment.events.submit))
示例#2
0
    def __init__(self, view):
        super().__init__(view, 'myform')

        new_comment = Comment()
        self.use_layout(FormLayout())
        self.layout.add_input( TextInput(self, new_comment.fields.email_address) )

        self.define_event_handler(new_comment.events.do_nothing)
        self.add_child(ButtonInput(self, new_comment.events.do_nothing))
示例#3
0
    def __init__(self, view, address):
        form_name = 'address_%s' % address.id  # Forms need unique names!
        super(AddressBox, self).__init__(view, form_name)

        par = self.add_child(
            P(view, text='%s: %s ' % (address.name, address.email_address)))
        par.add_child(
            ButtonInput(
                self,
                address.events.edit.with_arguments(address_id=address.id)))
示例#4
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'))
示例#5
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))
示例#6
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'))
示例#7
0
    def __init__(self, view, event_channel_name):
        super().__init__(view, event_channel_name)
        self.use_layout(FormLayout())
        model_object = ModelObject()
        self.layout.add_input(
            TextInput(self, model_object.fields.text_input_field))
        self.layout.add_input(
            CheckboxInput(self, model_object.fields.boolean_field))
        self.layout.add_input(
            PasswordInput(self, model_object.fields.password_field))
        self.layout.add_input(
            TextArea(self,
                     model_object.fields.text_area_field,
                     rows=5,
                     columns=60))
        self.layout.add_input(
            SelectInput(self, model_object.fields.choice_field))
        self.layout.add_input(
            SelectInput(self, model_object.fields.multi_choice_field))
        self.layout.add_input(
            CheckboxInput(self,
                          model_object.fields.another_multi_choice_field))
        self.layout.add_input(
            RadioButtonSelectInput(self,
                                   model_object.fields.radio_choice_field,
                                   contents_layout=ChoicesLayout(inline=True)))
        self.layout.add_input(
            TextInput(self, model_object.fields.fuzzy_date_field, fuzzy=True))
        self.layout.add_input(TextInput(
            self,
            model_object.fields.text_input_without_label,
            placeholder=True),
                              hide_label=True)
        self.layout.add_input(
            CueInput(TextInput(self, model_object.fields.cue_field),
                     P(view, text='This is a cue')))
        self.define_event_handler(model_object.events.do_something)

        self.add_child(
            ButtonInput(self,
                        model_object.events.do_something,
                        style='primary'))
示例#8
0
    def __init__(self, view):
        super().__init__(view, 'myform')

        new_comment = Comment()
        grouped_inputs = self.add_child(
            FieldSet(view, legend_text='Leave a comment'))
        grouped_inputs.use_layout(FormLayout())
        grouped_inputs.layout.add_input(
            TextInput(self, new_comment.fields.email_address))
        grouped_inputs.layout.add_input(
            TextInput(self, new_comment.fields.text))

        attachments = self.add_child(FieldSet(view,
                                              legend_text='Attach files'))
        attachments.use_layout(FormLayout())
        attachments.layout.add_input(FileUploadInput(
            self, new_comment.fields.uploaded_files),
                                     hide_label=True)

        self.define_event_handler(new_comment.events.submit)
        self.add_child(
            ButtonInput(self, new_comment.events.submit, style='primary'))