Beispiel #1
0
 def POST(self, id):
     form = field_form()
     data = web.input()
     mid = data.mid
     if not form.validates():
         req = web.ctx.req
         req.update({
             'form': form,
             'mid': mid,
             })
         return render.field_edit(**req)
     save_field(int(id), form.d)
     raise web.seeother('/model/%s/edit' % mid)
Beispiel #2
0
 def POST(self, id):
     data = web.input(options=[])
     form = FIELD_FORM_TYPE[data.type+'_form']()
     mid = data.mid
     if not form.validates():
         model = get_model(mid)
         if data.type == 'select' or data.type == 'radio' or data.type == 'checkbox':
             form.options.set_value(data.options)
         req = web.ctx.req
         req.update({
             'type': data.type,
             data.type+'_form': form,
             'mid': mid,
             'mtitle': model.title,
             })
         return render.field_edit(**req)
     form_data = form.d
     form_data.type = data.type
     form_data.options = data.options
     save_field(int(id), form_data)
     raise web.seeother('/model/%s/edit' % mid)