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)
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))
def profile_edit(request, template_name="profiles/profile_edit.html"): helper = FormHelper() submit = Submit('edit', 'Edit') helper.add_input(submit) reset = Reset('reset', 'Reset') helper.add_input(reset) profile = get_object_or_404(Profile, user=request.user) form = ProfileForm(request.POST or None, instance=profile) if form.is_valid(): form.save() msg = 'Profile edited' messages.add_message(request, messages.INFO, msg) return HttpResponseRedirect( reverse("profile_detail", kwargs={"username": profile.user.username})) return render_to_response(template_name, { "profile": profile, "form": form, "helper": helper, }, context_instance=RequestContext(request))
def set_helper(self): print "AadhaarLoginForm.helper In helper" #form = AadhaarLoginForm() helper = FormHelper() reset = Reset('', 'Reset') helper.add_input(reset) submit = Submit('', 'Authenticate') helper.add_input(submit) helper.form_action = '/aadhaar/authenticate/' + self.detail helper.form_method = 'POST' helper.form_class = "blueForms" style = """ <style> fieldset.formRow { margin-bottom: 1em; border-width: 0 0 1px 0; border-color:#CCCCCC; border-style:solid; } </style> """ common_layout = Layout( Fieldset( 'Required Parameters', 'aadhaar_id', 'aadhaar_attributes', )) pi_layout = Layout( Fieldset( "Personally Identifiable Information", 'aadhaar_pi_match', 'aadhaar_name', 'aadhaar_dob', 'aadhaar_age', 'aadhaar_gender', 'aadhaar_email', 'aadhaar_phone', )) pa_layout = Layout( Fieldset("Address", 'aadhaar_pa_match', 'aadhaar_co', 'aadhaar_house', 'aadhaar_street', 'aadhaar_landmark', 'aadhaar_locality', 'aadhaar_vtc', 'aadhaar_subdist', 'aadhaar_district', 'aadhaar_state', 'aadhaar_pincode', 'aadhaar_postoffice')) if self.detail == "personal": layout = Layout(common_layout, pi_layout) elif self.detail == "address": layout = Layout(common_layout, pa_layout) else: layout = Layout(common_layout, pi_layout, pa_layout) helper.layout = layout self.helper = helper
def helper(self): form = LoginForm() helper = FormHelper() reset = Reset('', 'Reset') helper.add_input(reset) submit = Submit('', 'Log In') helper.add_input(submit) helper.form_action = '/account/login' helper.form_method = 'POST' return helper
def helper(self): form = SignupForm() helper = FormHelper() reset = Reset('', 'Reset') helper.add_input(reset) submit = Submit('', 'Sign Up') helper.add_input(submit) helper.form_action = '/account/signup' helper.form_method = 'POST' return helper
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
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
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
class HelperTestForm(TestForm): # Attach a formHelper to your forms class. 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('enter','enter some data') helper.add_input(submit) reset = Reset('reset','reset button') helper.add_input(reset)
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
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) '''