Example #1
0
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}
Example #2
0
    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}
Example #3
0
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}
Example #4
0
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}
Example #5
0
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}
Example #6
0
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)
Example #7
0
def user_register_form(request):
    form = ZigguratForm(UserRegisterSchema)
    if request.method == 'POST':
        form.set_data(request.POST)
        form.validate()
    return {"form": form}
Example #8
0
def user_login_form(request):
    form = ZigguratForm(UserLoginSchema)
    if request.method == 'POST':
        form.set_data(request.POST)
        form.validate()
    return {"form": form}
Example #9
0
def user_register_form(request):
    form = ZigguratForm(UserRegisterSchema)
    if request.method == 'POST':
        form.set_data(request.POST)
        form.validate()
    return {"form": form}
Example #10
0
def user_login_form(request):
    form = ZigguratForm(UserLoginSchema)
    if request.method == 'POST':
        form.set_data(request.POST)
        form.validate()
    return {"form": form}