Exemple #1
0
    def add_choice(self, html_input):
        input_type_custom_control = HTMLAttributeValueOption(
            html_input.choice_type,
            True,
            prefix='custom',
            constrain_value_to=['radio', 'checkbox'])

        label_widget = Label(self.view, for_input=html_input)
        label_widget.append_class('custom-control-label')

        html_input.append_class('custom-control-input')

        outer_div = Div(self.view)
        outer_div.append_class('custom-control')
        outer_div.append_class(input_type_custom_control.as_html_snippet())
        if self.inline:
            outer_div.append_class('custom-control-inline')
        if html_input.disabled:
            outer_div.append_class('disabled')

        outer_div.add_child(html_input)
        outer_div.add_child(label_widget)

        self.widget.add_child(outer_div)

        return outer_div
 def __init__(self, view, an_object):
     super(MyForm, self).__init__(view, 'myform')
     self.enable_refresh()
     self.change_trigger_input = fixture.create_trigger_input(self, an_object)
     self.add_child(Label(view, for_input=self.change_trigger_input))
     self.add_child(self.change_trigger_input)
     self.add_child(P(self.view, text='My state is now %s' % an_object.choice))
 def __init__(self, view, an_object):
     super(MyForm, self).__init__(view, 'myform')
     self.an_object = an_object
     self.enable_refresh(on_refresh=an_object.events.choice_changed)
     if self.exception:
         self.add_child(P(self.view, text=str(self.exception)))
     self.change_trigger_input = TextInput(self, an_object.fields.choice, refresh_widget=self)
     self.add_child(Label(view, for_input=self.change_trigger_input))
     self.add_child(self.change_trigger_input)
     self.add_child(P(self.view, text='My choice state is now %s' % an_object.choice))
     self.change3_non_trigger_input = TextInput(self, an_object.fields.choice3)
     self.add_child(Label(view, for_input=self.change3_non_trigger_input))
     self.add_child(self.change3_non_trigger_input)
     self.add_child(P(self.view, text='My calculated state is now %s' % an_object.calculated_state))
     self.define_event_handler(an_object.events.submit)
     self.add_child(ButtonInput(self, an_object.events.submit))
Exemple #4
0
 def input_label_with_text(self):
     html_input = TextInput(self.form, self.field)
     self.widget = Label(self.web_fixture.view,
                         for_input=html_input,
                         text='some text')
     self.expected_html = '<label for="%s">some text</label>' % html_input.css_id
     self.field_controls_visibility = True
Exemple #5
0
    def __init__(self, view):
        super(AddAddressForm, self).__init__(view, 'add_form')

        new_address = Address()

        grouped_inputs = self.add_child(
            FieldSet(view, legend_text='Add an address'))
        name_input = TextInput(self, new_address.fields.name)
        grouped_inputs.add_child(Label(view, for_input=name_input))
        grouped_inputs.add_child(name_input)

        email_input = TextInput(self, new_address.fields.email_address)
        grouped_inputs.add_child(Label(view, for_input=email_input))
        grouped_inputs.add_child(email_input)

        self.define_event_handler(new_address.events.save)
        grouped_inputs.add_child(ButtonInput(self, new_address.events.save))
            def __init__(self, view):
                super(MyForm, self).__init__(view, 'myform')
                self.enable_refresh()
                if self.exception:
                    self.add_child(P(view, text='Exception raised'))

                model_object = ModelObject()
                checkbox_input = fixture.trigger_input_type(self, model_object.fields.trigger_field, refresh_widget=self)
                self.add_child(Label(view, for_input=checkbox_input))
                self.add_child(checkbox_input)

                if model_object.trigger_field:
                    email_input = TextInput(self, model_object.fields.email)
                    self.add_child(Label(self.view, for_input=email_input))
                    self.add_child(email_input)

                self.define_event_handler(model_object.events.an_event)
                self.add_child(ButtonInput(self, model_object.events.an_event))
Exemple #7
0
 def add_label_to(self, form_group, html_input, hidden):
     if isinstance(html_input, RadioButtonSelectInput):
         label = form_group.add_child(Legend(self.view, text=html_input.label))
         label.append_class('col-form-label')
     else:
         label = form_group.add_child(Label(self.view, for_input=html_input))
     if hidden:
         label.append_class('sr-only')
     return label
            def __init__(self, form, model_object):
                self.model_object = model_object
                super(MyNestedChangingWidget, self).__init__(form.view, css_id='nested_changing_widget')
                self.enable_refresh()

                nested_checkbox_input = CheckboxInput(form, model_object.fields.nested_trigger_field, refresh_widget=self)
                self.add_child(Label(self.view, for_input=nested_checkbox_input))
                self.add_child(nested_checkbox_input)

                if self.model_object.nested_trigger_field:
                    self.add_child(P(self.view, 'My state is now showing nested responsive content'))
            def __init__(self, view):
                super(MyForm, self).__init__(view, 'myform')
                self.enable_refresh()
                model_object = fixture.ModelObject()

                checkbox_input = CheckboxInput(self, model_object.fields.trigger_field, refresh_widget=self)
                self.add_child(Label(self.view, for_input=checkbox_input))
                self.add_child(checkbox_input)

                if model_object.trigger_field:
                    self.add_child(P(self.view, 'My state is now showing outer responsive content'))
                    self.add_child(MyNestedChangingWidget(self, model_object))
 def add_to_form(form, model_object):
     text_input = TextInput(form, model_object.fields.calculated_state)
     form.add_child(Label(form.view, for_input=text_input))
     form.add_child(text_input)
     form.add_child(P(form.view, text='Status: %s' % text_input.get_input_status()))
 def __init__(self, view, an_object):
     super(MyForm, self).__init__(view, an_object)
     another_model_object = fixture.ModelObject()
     another_input = CheckboxSelectInput(self, another_model_object.fields.choice)
     self.add_child(Label(view, for_input=another_input))
     self.add_child(another_input)
Exemple #12
0
 def input_label(self):
     html_input = TextInput(self.form, self.field)
     self.widget = Label(self.view, for_input=html_input)
     self.expected_html = r'<label for="%s">the label</label>' % html_input.css_id
     self.field_controls_visibility = True
Exemple #13
0
 def input_label(self):
     html_input = TextInput(self.form, self.field)
     self.widget = Label(self.web_fixture.view, for_input=html_input)
     self.expected_html = '<label for="%s">the label</label>' % html_input.css_id
     self.bound_field = html_input.bound_field