def phones_form(request): form = ZigguratForm(PhonesSchema) data = { "prefix": 1, "aaaa": "bbbb", "phones": [{ 'number': '1', 'location': 'dadada' }, { 'y': 5 }, { 'number': 'abc' }, {}, { 'location': 'warsaw', 'number': 123 }], "suffix": "bla" } if request.method == 'POST': form.set_data(request.POST) form.validate() else: form.set_data(data) return {"form": form}
def form_view(self, request, data): form = ZigguratForm(self.form) if request.method == 'POST': form.set_data(request.POST) form.validate() elif data: form.set_data(data) return {"form": form}
def basic_form(request): data = {'password': '******', "phones": [{}], "subperson": {}, "user_name": "us"} form = ZigguratForm(UserSchema) if request.method == 'POST': form.set_data(request.POST) form.validate() else: form.set_data(data) return {"form": form}
def basic_form(request): data = { 'password': '******', "phones": [{}], "subperson": {}, "user_name": "us" } form = ZigguratForm(UserSchema) if request.method == 'POST': form.set_data(request.POST) form.validate() else: form.set_data(data) return {"form": form}
def phones_form(request): form = ZigguratForm(PhonesSchema) data = { "prefix": 1, "aaaa": "bbbb", "phones": [{'number': '1', 'location': 'dadada'}, {'y': 5}, {'number': 'abc'}, {}, {'location': 'warsaw', 'number': 123}], "suffix": "bla" } if request.method == 'POST': form.set_data(request.POST) form.validate() else: form.set_data(data) return {"form": form}
from ziggurat_form.test_schemas import UserSchema from ziggurat_form.form import ZigguratForm data = {'password':'******'} form = ZigguratForm(UserSchema) form.set_data(data) form.validate() def render_field(field): print('--------------') if field.widget: print('label:"{}", req:{}'.format(field.widget.label, field.widget.required)) if field.widget.errors: print('errors:', field.widget.errors) print(field.widget()) if field.children: print('peppercorn marker START') for subfield in field.children: render_field(subfield) print('peppercorn marker END') for field in form: render_field(field) print('FORM ERRORS:', form.errors)
def user_register_form(request): form = ZigguratForm(UserRegisterSchema) if request.method == 'POST': form.set_data(request.POST) form.validate() return {"form": form}
def user_login_form(request): form = ZigguratForm(UserLoginSchema) if request.method == 'POST': form.set_data(request.POST) form.validate() return {"form": form}