本文整理汇总了Python中uni_form.helpers.FormHelper.form_error_title方法的典型用法代码示例。如果您正苦于以下问题:Python FormHelper.form_error_title方法的具体用法?Python FormHelper.form_error_title怎么用?Python FormHelper.form_error_title使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类uni_form.helpers.FormHelper
的用法示例。
在下文中一共展示了FormHelper.form_error_title方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_uni_form_with_helper_attributes_without_layout
# 需要导入模块: from uni_form.helpers import FormHelper [as 别名]
# 或者: from uni_form.helpers.FormHelper import form_error_title [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)
示例2: test_uni_form_with_helper_without_layout
# 需要导入模块: from uni_form.helpers import FormHelper [as 别名]
# 或者: from uni_form.helpers.FormHelper import form_error_title [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)