Exemple #1
0
    def test_uni_form_helper_inputs(self):
        form_helper = FormHelper()
        submit = Submit('my-submit', 'Submit', css_class="button white")
        reset = Reset('my-reset', 'Reset')
        hidden = Hidden('my-hidden', 'Hidden')
        button = Button('my-button', 'Button')
        form_helper.add_input(submit)
        form_helper.add_input(reset)
        form_helper.add_input(hidden)
        form_helper.add_input(button)

        template = get_template_from_string(u"""
            {% load uni_form_tags %}
            {% uni_form form form_helper %}
        """)
        c = Context({'form': TestForm(), 'form_helper': form_helper})
        html = template.render(c)

        self.assertTrue('class="submit submitButton button white"' in html)
        self.assertTrue('id="submit-id-my-submit"' in html)

        self.assertTrue('class="reset resetButton"' in html)
        self.assertTrue('id="reset-id-my-reset"' in html)

        self.assertTrue('name="my-hidden"' in html)

        self.assertTrue('class="button"' in html)
        self.assertTrue('id="button-id-my-button"' in html)
Exemple #2
0
def view_helper(request):
    # Create the form
    if request.method == "POST":
        form = TestForm(request.POST)
    else:
        form = TestForm()

    # create a formHelper
    helper = FormHelper()

    # Add in a class and id
    helper.form_id = 'this-form-rocks'
    helper.form_class = 'search'

    # add in a submit and reset button
    submit = Submit('search', 'search this site')
    helper.add_input(submit)
    reset = Reset('reset', 'reset button')
    helper.add_input(reset)
    hidden = Hidden('not-seen', 'hidden value stored here')
    helper.add_input(hidden)

    # create the response dictionary
    response_dictionary = {
        'form': form,
        'helper': helper,
        'title': 'view helper test'
    }

    return render_to_response('test_app/generic_form_test.html',
                              response_dictionary,
                              context_instance=RequestContext(request))
Exemple #3
0
    def test_uni_form_helper_inputs(self):

        form_helper = FormHelper()
        submit = Submit('my-submit', 'Submit')
        reset = Reset('my-reset', 'Reset')
        hidden = Hidden('my-hidden', 'Hidden')
        button = Button('my-button', 'Button')
        form_helper.add_input(submit)
        form_helper.add_input(reset)
        form_helper.add_input(hidden)
        form_helper.add_input(button)

        c = Context({'form': TestForm(), 'form_helper': form_helper})

        template = get_template_from_string("""
{% load uni_form_tags %}
{% uni_form form form_helper %}
        """)
        html = template.render(c)
        '''