예제 #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}
예제 #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}
예제 #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}
예제 #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}
예제 #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}
예제 #6
0
파일: test.py 프로젝트: netme/ziggurat_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)
예제 #7
0
def user_register_form(request):
    form = ZigguratForm(UserRegisterSchema)
    if request.method == 'POST':
        form.set_data(request.POST)
        form.validate()
    return {"form": form}
예제 #8
0
def user_login_form(request):
    form = ZigguratForm(UserLoginSchema)
    if request.method == 'POST':
        form.set_data(request.POST)
        form.validate()
    return {"form": form}
예제 #9
0
def user_register_form(request):
    form = ZigguratForm(UserRegisterSchema)
    if request.method == 'POST':
        form.set_data(request.POST)
        form.validate()
    return {"form": form}
예제 #10
0
def user_login_form(request):
    form = ZigguratForm(UserLoginSchema)
    if request.method == 'POST':
        form.set_data(request.POST)
        form.validate()
    return {"form": form}