本文整理汇总了Python中uni_form.helpers.FormHelper.form_action方法的典型用法代码示例。如果您正苦于以下问题:Python FormHelper.form_action方法的具体用法?Python FormHelper.form_action怎么用?Python FormHelper.form_action使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类uni_form.helpers.FormHelper
的用法示例。
在下文中一共展示了FormHelper.form_action方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: helper
# 需要导入模块: from uni_form.helpers import FormHelper [as 别名]
# 或者: from uni_form.helpers.FormHelper import form_action [as 别名]
def helper(self):
"""django-uni-form layout specification."""
helper = FormHelper()
if self.instance and self.instance.id:
helper.form_action = reverse("media-edit", args=[self.instance.id])
delete = Button("delete", "Delete This Item", css_class="secondaryAction")
helper.add_input(delete)
else:
helper.form_action = reverse("media-add")
another = Submit("save_add", "Save and Add Another", css_class="primaryAction")
helper.add_input(another)
submit = Submit("save", "Save", css_class="primaryAction")
helper.add_input(submit)
helper.form_method = "POST"
return helper
示例2: test_uni_form_formset_with_helper_without_layout
# 需要导入模块: from uni_form.helpers import FormHelper [as 别名]
# 或者: from uni_form.helpers.FormHelper import form_action [as 别名]
def test_uni_form_formset_with_helper_without_layout(self):
template = get_template_from_string(u"""
{% load uni_form_tags %}
{% uni_form testFormSet formset_helper %}
""")
form_helper = FormHelper()
form_helper.form_id = 'thisFormsetRocks'
form_helper.form_class = 'formsets-that-rock'
form_helper.form_method = 'POST'
form_helper.form_action = 'simpleAction'
TestFormSet = formset_factory(TestForm, extra = 3)
testFormSet = TestFormSet()
c = Context({'testFormSet': testFormSet, 'formset_helper': form_helper, 'csrf_token': _get_new_csrf_key()})
html = template.render(c)
self.assertEqual(html.count('<form'), 1)
self.assertEqual(html.count("<input type='hidden' name='csrfmiddlewaretoken'"), 1)
# Check formset management form
self.assertTrue('form-TOTAL_FORMS' in html)
self.assertTrue('form-INITIAL_FORMS' in html)
self.assertTrue('form-MAX_NUM_FORMS' in html)
self.assertTrue('class="uniForm formsets-that-rock"' in html)
self.assertTrue('method="post"' in html)
self.assertTrue('id="thisFormsetRocks">' in html)
self.assertTrue('action="%s"' % reverse('simpleAction') in html)
示例3: test_uni_form_formset
# 需要导入模块: from uni_form.helpers import FormHelper [as 别名]
# 或者: from uni_form.helpers.FormHelper import form_action [as 别名]
def test_uni_form_formset(self):
template = get_template_from_string(u"""
{% load uni_form_tags %}
{% uni_form testFormSet formset_helper %}
""")
form_helper = FormHelper()
form_helper.form_id = 'this-formset-rocks'
form_helper.form_class = 'formsets-that-rock'
form_helper.form_method = 'GET'
form_helper.form_action = 'simpleAction'
from django.forms.models import formset_factory
TestFormSet = formset_factory(TestForm, extra = 3)
testFormSet = TestFormSet()
c = Context({'testFormSet': testFormSet, 'formset_helper': form_helper})
html = template.render(c)
self.assertTrue('<form' in html)
self.assertEqual(html.count('<form'), 1)
self.assertTrue('class="uniForm formsets-that-rock"' in html)
self.assertTrue('method="get"' in html)
self.assertTrue('id="this-formset-rocks">' in html)
self.assertTrue('action="%s"' % reverse('simpleAction') in html)
示例4: helper
# 需要导入模块: from uni_form.helpers import FormHelper [as 别名]
# 或者: from uni_form.helpers.FormHelper import form_action [as 别名]
def helper(self):
helper = FormHelper()
helper.add_input(Submit('submit', _('Search')))
helper.form_action = reverse('search:search')
helper.form_method = 'get'
return helper
示例5: test_uni_form_with_helper_attributes
# 需要导入模块: from uni_form.helpers import FormHelper [as 别名]
# 或者: from uni_form.helpers.FormHelper import form_action [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)
示例6: test_uni_form_formset
# 需要导入模块: from uni_form.helpers import FormHelper [as 别名]
# 或者: from uni_form.helpers.FormHelper import form_action [as 别名]
def test_uni_form_formset(self):
template = get_template_from_string(
u"""
{% load uni_form_tags %}
{% uni_form testFormSet formset_helper %}
"""
)
form_helper = FormHelper()
form_helper.form_id = "thisFormsetRocks"
form_helper.form_class = "formsets-that-rock"
form_helper.form_method = "POST"
form_helper.form_action = "simpleAction"
TestFormSet = formset_factory(TestForm, extra=3)
testFormSet = TestFormSet()
c = Context({"testFormSet": testFormSet, "formset_helper": form_helper, "csrf_token": _get_new_csrf_key()})
html = template.render(c)
self.assertEqual(html.count("<form"), 1)
self.assertEqual(html.count("<input type='hidden' name='csrfmiddlewaretoken'"), 1)
self.assertTrue('class="uniForm formsets-that-rock"' in html)
self.assertTrue('method="post"' in html)
self.assertTrue('id="thisFormsetRocks">' in html)
self.assertTrue('action="%s"' % reverse("simpleAction") in html)
示例7: helper
# 需要导入模块: from uni_form.helpers import FormHelper [as 别名]
# 或者: from uni_form.helpers.FormHelper import form_action [as 别名]
def helper(self):
helper = FormHelper()
submit = Submit('submit', 'Submit your application')
helper.add_input(submit)
helper.form_action = self.form_action
helper.form_method = 'POST'
return helper
示例8: helper
# 需要导入模块: from uni_form.helpers import FormHelper [as 别名]
# 或者: from uni_form.helpers.FormHelper import form_action [as 别名]
def helper(self):
form = CreateClientForm()
helper = FormHelper()
reset = Reset('','Reset')
helper.add_input(reset)
submit = Submit('','Create Client')
helper.add_input(submit)
helper.form_action = '/account/clients'
helper.form_method = 'POST'
return helper
示例9: helper
# 需要导入模块: from uni_form.helpers import FormHelper [as 别名]
# 或者: from uni_form.helpers.FormHelper import form_action [as 别名]
def helper(self):
form = LoginForm()
helper = FormHelper()
reset = Reset('','Reset')
helper.add_input(reset)
submit = Submit('','Authenticate')
helper.add_input(submit)
helper.form_action = '/account/aadhaar/authenticate'
helper.form_method = 'POST'
return helper
示例10: helper
# 需要导入模块: from uni_form.helpers import FormHelper [as 别名]
# 或者: from uni_form.helpers.FormHelper import form_action [as 别名]
def helper(self):
form = GroupForm()
helper = FormHelper()
reset = Reset("", "Reset")
helper.add_input(reset)
submit = Submit("", "Create Group")
helper.add_input(submit)
helper.form_action = "/account/groups"
helper.form_method = "POST"
return helper
示例11: set_helper
# 需要导入模块: from uni_form.helpers import FormHelper [as 别名]
# 或者: from uni_form.helpers.FormHelper import form_action [as 别名]
def set_helper(self):
helper = FormHelper()
reset = Reset('','Reset')
helper.add_input(reset)
submit = Submit('','Submit')
helper.add_input(submit)
helper.form_action = ''
helper.form_method = 'POST'
helper.form_class="blueForms"
self.helper = helper
示例12: test_formset_layout
# 需要导入模块: from uni_form.helpers import FormHelper [as 别名]
# 或者: from uni_form.helpers.FormHelper import form_action [as 别名]
def test_formset_layout(self):
template = get_template_from_string(u"""
{% load uni_form_tags %}
{% uni_form testFormSet formset_helper %}
""")
form_helper = FormHelper()
form_helper.form_id = 'thisFormsetRocks'
form_helper.form_class = 'formsets-that-rock'
form_helper.form_method = 'POST'
form_helper.form_action = 'simpleAction'
form_helper.add_layout(
Layout(
Fieldset("Item {{ forloop.counter }}",
'is_company',
'email',
),
HTML("{% if forloop.first %}Note for first form only{% endif %}"),
Row('password1', 'password2'),
Fieldset("",
'first_name',
'last_name'
)
)
)
TestFormSet = formset_factory(TestForm, extra = 3)
testFormSet = TestFormSet()
c = Context({
'testFormSet': testFormSet,
'formset_helper': form_helper,
'csrf_token': _get_new_csrf_key()
})
html = template.render(c)
# Check form parameters
self.assertEqual(html.count('<form'), 1)
self.assertEqual(html.count("<input type='hidden' name='csrfmiddlewaretoken'"), 1)
self.assertTrue('class="uniForm formsets-that-rock"' in html)
self.assertTrue('method="post"' in html)
self.assertTrue('id="thisFormsetRocks">' in html)
self.assertTrue('action="%s"' % reverse('simpleAction') in html)
# Check form layout
self.assertTrue('Item 1' in html)
self.assertTrue('Item 2' in html)
self.assertTrue('Item 3' in html)
self.assertEqual(html.count('Note for first form only'), 1)
self.assertEqual(html.count('formRow'), 3)
示例13: helper
# 需要导入模块: from uni_form.helpers import FormHelper [as 别名]
# 或者: from uni_form.helpers.FormHelper import form_action [as 别名]
def helper(self):
print "ProfileForm.helper In helper"
form = ProfileForm()
helper = FormHelper()
reset = Reset('','Reset')
helper.add_input(reset)
submit = Submit('','Update')
helper.add_input(submit)
helper.form_action = '/account/profile/edit'
helper.form_method = 'POST'
helper.form_class="blueForms"
return helper
示例14: test_formset_layout
# 需要导入模块: from uni_form.helpers import FormHelper [as 别名]
# 或者: from uni_form.helpers.FormHelper import form_action [as 别名]
def test_formset_layout(self):
template = get_template_from_string(
u"""
{% load uni_form_tags %}
{% uni_form testFormSet formset_helper %}
"""
)
form_helper = FormHelper()
form_helper.form_id = "thisFormsetRocks"
form_helper.form_class = "formsets-that-rock"
form_helper.form_method = "POST"
form_helper.form_action = "simpleAction"
form_helper.add_layout(
Layout(
Fieldset("Item {{ forloop.counter }}", "is_company", "email"),
HTML("{% if forloop.first %}Note for first form only{% endif %}"),
Row("password1", "password2"),
Fieldset("", "first_name", "last_name"),
)
)
TestFormSet = formset_factory(TestForm, extra=3)
testFormSet = TestFormSet()
c = Context({"testFormSet": testFormSet, "formset_helper": form_helper, "csrf_token": _get_new_csrf_key()})
html = template.render(c)
# Check form parameters
self.assertEqual(html.count("<form"), 1)
self.assertEqual(html.count("<input type='hidden' name='csrfmiddlewaretoken'"), 1)
self.assertTrue('class="uniForm formsets-that-rock"' in html)
self.assertTrue('method="post"' in html)
self.assertTrue('id="thisFormsetRocks">' in html)
self.assertTrue('action="%s"' % reverse("simpleAction") in html)
# Check form layout
self.assertTrue("Item 1" in html)
self.assertTrue("Item 2" in html)
self.assertTrue("Item 3" in html)
self.assertEqual(html.count("Note for first form only"), 1)
self.assertEqual(html.count("formRow"), 3)
示例15: helper
# 需要导入模块: from uni_form.helpers import FormHelper [as 别名]
# 或者: from uni_form.helpers.FormHelper import form_action [as 别名]
def helper(self):
form = HelperAuthenticationForm()
helper = FormHelper()
login = Submit('login','Submit',css_class='primaryAction')
helper.add_input(login)
helper.form_action = 'login_form'
helper.form_method = 'POST' # Only GET and POST are legal
layout = Layout(
Fieldset('',
HTML('<input type="hidden" name="next" value="{{ request.GET.next }}" />'),
'identification', 'password', 'remember_me', css_class='inlineLabels'),
)
helper.add_layout(layout)
return helper