本文整理汇总了Python中uni_form.helpers.FormHelper.form_tag方法的典型用法代码示例。如果您正苦于以下问题:Python FormHelper.form_tag方法的具体用法?Python FormHelper.form_tag怎么用?Python FormHelper.form_tag使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类uni_form.helpers.FormHelper
的用法示例。
在下文中一共展示了FormHelper.form_tag方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_uni_form_with_helper_attributes
# 需要导入模块: from uni_form.helpers import FormHelper [as 别名]
# 或者: from uni_form.helpers.FormHelper import form_tag [as 别名]
def test_uni_form_with_helper_attributes(self):
form_helper = FormHelper()
form_helper.form_id = 'this-form-rocks'
form_helper.form_class = 'forms-that-rock'
form_helper.form_method = 'GET'
form_helper.form_action = 'simpleAction'
template = get_template_from_string(u"""
{% load uni_form_tags %}
{% uni_form form form_helper %}
""")
# now we render it
c = Context({'form': TestForm(), 'form_helper': form_helper})
html = template.render(c)
# Lets make sure everything loads right
self.assertTrue('<form' in html)
self.assertTrue('class="uniForm forms-that-rock"' in html)
self.assertTrue('method="get"' in html)
self.assertTrue('id="this-form-rocks">' in html)
self.assertTrue('action="%s"' % reverse('simpleAction') in html)
# now lets remove the form tag and render it again. All the True items above
# should now be false because the form tag is removed.
form_helper.form_tag = False
html = template.render(c)
self.assertFalse('<form' in html)
self.assertFalse('class="uniForm forms-that-rock"' in html)
self.assertFalse('method="get"' in html)
self.assertFalse('id="this-form-rocks">' in html)
示例2: test_uni_form_helper_form_attributes
# 需要导入模块: from uni_form.helpers import FormHelper [as 别名]
# 或者: from uni_form.helpers.FormHelper import form_tag [as 别名]
def test_uni_form_helper_form_attributes(self):
template = get_template_from_string("""
{% load uni_form_tags %}
{% uni_form form form_helper %}
""")
# First we build a standard form helper
form_helper = FormHelper()
form_helper.form_id = 'this-form-rocks'
form_helper.form_class = 'forms-that-rock'
form_helper.form_method = 'GET'
# now we render it
c = Context({'form':TestForm(),'form_helper':form_helper})
html = template.render(c)
# Lets make sure everything loads right
self.assertTrue("""<form""" in html)
self.assertTrue("""class="uniForm forms-that-rock" """ in html)
self.assertTrue("""method="get" """ in html)
self.assertTrue("""id="this-form-rocks">""" in html)
# now lets remove the form tag and render it again. All the True items above
# should now be false because the form tag is removed.
form_helper.form_tag = False
c = Context({'form':TestForm(),'form_helper':form_helper})
html = template.render(c)
self.assertFalse("""<form""" in html)
self.assertFalse("""id="this-form-rocks">""" in html)
self.assertFalse("""class="uniForm forms-that-rock" """ in html)
self.assertFalse("""method="get" """ in html)
self.assertFalse("""id="this-form-rocks">""" in html)
示例3: lacking_form_tag
# 需要导入模块: from uni_form.helpers import FormHelper [as 别名]
# 或者: from uni_form.helpers.FormHelper import form_tag [as 别名]
def lacking_form_tag(request):
# Create the form
if request.method == "POST":
form = TestForm(request.POST)
else:
form = TestForm()
# create a formHelper
helper = FormHelper()
# remove the form tag
helper.form_tag = False
# create the response dictionary
response_dictionary = {'form':form, 'helper': helper, 'title':'Lacking Form Tag Test'}
return render_to_response('test_app/generic_form_test.html',
response_dictionary,
context_instance=RequestContext(request))
示例4: test_uni_form_with_helper_attributes_without_layout
# 需要导入模块: from uni_form.helpers import FormHelper [as 别名]
# 或者: from uni_form.helpers.FormHelper import form_tag [as 别名]
def test_uni_form_with_helper_attributes_without_layout(self):
form_helper = FormHelper()
form_helper.form_id = "this-form-rocks"
form_helper.form_class = "forms-that-rock"
form_helper.form_method = "GET"
form_helper.form_action = "simpleAction"
form_helper.form_error_title = "ERRORS"
template = get_template_from_string(
u"""
{% load uni_form_tags %}
{% uni_form testForm form_helper %}
"""
)
# now we render it, with errors
form = TestForm({"password1": "wargame", "password2": "god"})
form.is_valid()
c = Context({"testForm": form, "form_helper": form_helper})
html = template.render(c)
# Lets make sure everything loads right
self.assertTrue("<form" in html)
self.assertTrue('class="uniForm forms-that-rock"' in html)
self.assertTrue('method="get"' in html)
self.assertTrue('id="this-form-rocks">' in html)
self.assertTrue('action="%s"' % reverse("simpleAction") in html)
self.assertTrue("<h3>ERRORS</h3>" in html)
self.assertTrue("<li>Passwords dont match</li>" in html)
# now lets remove the form tag and render it again. All the True items above
# should now be false because the form tag is removed.
form_helper.form_tag = False
html = template.render(c)
self.assertFalse("<form" in html)
self.assertFalse('class="uniForm forms-that-rock"' in html)
self.assertFalse('method="get"' in html)
self.assertFalse('id="this-form-rocks">' in html)
示例5: test_uni_form_with_helper_without_layout
# 需要导入模块: from uni_form.helpers import FormHelper [as 别名]
# 或者: from uni_form.helpers.FormHelper import form_tag [as 别名]
def test_uni_form_with_helper_without_layout(self):
form_helper = FormHelper()
form_helper.form_id = 'this-form-rocks'
form_helper.form_class = 'forms-that-rock'
form_helper.form_method = 'GET'
form_helper.form_action = 'simpleAction'
form_helper.form_error_title = 'ERRORS'
template = get_template_from_string(u"""
{% load uni_form_tags %}
{% uni_form testForm form_helper %}
""")
# now we render it, with errors
form = TestForm({'password1': 'wargame','password2': 'god'})
form.is_valid()
c = Context({'testForm': form, 'form_helper': form_helper})
html = template.render(c)
# Lets make sure everything loads right
self.assertTrue(html.count('<form'), 1)
self.assertTrue('class="uniForm forms-that-rock"' in html)
self.assertTrue('method="get"' in html)
self.assertTrue('id="this-form-rocks">' in html)
self.assertTrue('action="%s"' % reverse('simpleAction') in html)
self.assertEqual(html.count('<fieldset'), 1)
self.assertTrue("<h3>ERRORS</h3>" in html)
self.assertTrue("<li>Passwords dont match</li>" in html)
# now lets remove the form tag and render it again. All the True items above
# should now be false because the form tag is removed.
form_helper.form_tag = False
html = template.render(c)
self.assertFalse('<form' in html)
self.assertFalse('class="uniForm forms-that-rock"' in html)
self.assertFalse('method="get"' in html)
self.assertFalse('id="this-form-rocks">' in html)