Example #1
0
 def __init__(self, view, name):
     super(MyForm, self).__init__(view, name)
     checkbox = self.add_child(
         CheckboxInput(self, model_object.fields.an_attribute))
     self.define_event_handler(model_object.events.an_event)
     self.add_child(ButtonInput(self, model_object.events.an_event))
     fixture.checkbox = checkbox
Example #2
0
def test_checkbox_input_restricted_to_use_with_boolean(web_fixture):
    """CheckboxInput is for toggling a true or false answer."""
    model_object = web_fixture
    form = Form(web_fixture.view, 'test')

    # case: with BooleanField
    boolean_field = BooleanField(label='Boolean')
    boolean_field.bind('a_choice', model_object)
    with expected(NoException):
        CheckboxInput(form, boolean_field)

    # case: with disallowed field
    not_a_boolean_field = IntegerField(label='Other')
    not_a_boolean_field.bind('not_a_boolean', model_object)

    with expected(IsInstance):
        CheckboxInput(form, not_a_boolean_field)
Example #3
0
    def setup_checkbox_scenario(self, boolean_value):
        self.model_object.an_attribute = boolean_value

        self.field = BooleanField(required=True, label='my text', required_message='$label is needed here')
        self.field.bind('an_attribute', self.model_object)

        self.widget = self.form.add_child(CheckboxInput(self.form, self.field))
        self.field_controls_visibility = True
            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 create_trigger_input(form, an_object):
     the_input = CheckboxInput(form, an_object.fields.choice, refresh_widget=form)
     the_input.set_id('marvin')
     return the_input