No. There are lots of errors in the code mostly here: if auth.has_membership(auth.id_group('tech')): form = crud.create(db.atable) ... if form.accepts(request.vars, session):
1) you cannot form.accept a crud form. crud forms already accept internally. 2) even if you use a normal SQLFORM instead of a crud form, what if the first if is false and the second it true? On 13 Lug, 09:49, Jean-Guy <jean...@gmail.com> wrote: > Hello, > > I would like to make sure if it is my function that is not correct or > the crud.update behavior... > > Here are my create function and update fuction : > > @auth.requires_login() > def create(): > if auth.has_membership(auth.id_group('tech')): > form = crud.create(db.atable) > db.atable.initials.default=auth.user and auth.user.initials > db.atable.initials_date.default=request.now > if form.accepts(request.vars, session): > response.flash = T('form accepted') > redirect(URL(somewhere)) > elif form.errors: > response.flash = T('form has errors') > else: > response.flash = T('please fill out the form') > return dict(form=form) > > @auth.requires_login() > def update(): > if auth.has_membership(auth.id_group('tech')): > form=crud.update(db.atable,request.args[1],deletable=False) > db.atable.initials.default=auth.user and auth.user.initials > db.atable.initials_date.default=request.now > if form.accepts(request.vars, session): > response.flash = T('form accepted') > redirect(URL(somewhere)) > elif form.errors: > response.flash = T('form has errors') > else: > response.flash = T('please correct the form') > return dict(form=form) > > The problematic lines are in red in the function update > > The database field initials is not updated when the update form is submit... > > Is it normal? > > Could it be reliated to .default= ?? > > I thought the problem were coming from the next argument that were > included in the crud.update like this : > > form=crud.update(db.atable, > request.args[1], > next=URL(request.application,'home','index'), > deletable=False) > > So i change it for what I wrote up there... > > Thanks. > > Jonhy