Thanks Massimo.

It's impossible to have better support than web2py, you and this
community are impressing, five stars!

So, assumming I'm doing other things between the crud.create and the
return:

def index():
   form = crud.create(db.contents,message='Inserted')
   ... #other code
   return dict(form=form, other_variables...)

Question is: what's the best way for checking if the crud "accepted"
the input, and a new record was created? I just got it working by
checking if form.vars.id != None, but is there a better or official
way of doing it?

Thanks.

On 9 sep, 22:31, mdipierro <mdipie...@cs.depaul.edu> wrote:
> because you cannot ".accepts" a crud forms. It is implicit. You can do
>
> def index():
>    form = crud.create(db.contents,message='Inserted')
>    return dict(form=form)
>
> On Sep 9, 2:51 pm, Álvaro J. Iradier <airad...@gmail.com> wrote:
>
>
>
> > Hi, I think I found a problem (bug?) with crud.create and
> > form.custom.end:
>
> > I have the following model:
>
> > db.define_table('contents',
> >    Field('name', 'string', required=True, notnull=True,
> > requires=IS_NOT_EMPTY()),
> >    Field('ordering', 'integer', required=True,
> > requires=IS_NOT_EMPTY()),
> >    Field('duration', 'integer', required=True,
> > requires=IS_NOT_EMPTY()),
> >    Field('enabled', 'boolean', required=True),
> >    Field('file', 'upload', required=True, requires=IS_NOT_EMPTY(),
> > autodelete=True)
> > )
>
> > The following controller:
>
> > def index():
> >    form = crud.create(db.contents)
> >    if form.accepts(request.vars):
> >        response.flash='Inserted'
> >    return dict(form=form)
>
> > and the serialization of form.custom.end is:
>
> > <div class="hidden"><input name="_next" type="hidden" /><input
> > name="_formkey" type="hidden"
> > value="b1b19180-5226-48da-8d26-da29ed904177" /><input name="_formname"
> > type="hidden" value="contents_create" /></div><div
> > class="hidden"><input name="_next" type="hidden" /><input
> > name="_formkey" type="hidden"
> > value="b1b19180-5226-48da-8d26-da29ed904177" /><input name="_formname"
> > type="hidden" value="contents/None" /></div></form>
>
> > Notice the output is duplicated, specially "_formname" is repeated
> > with a value of "contents/None", which makes the form not working.
>
> > Am I doing something wrong, or is this a bug?
>
> > Thanks very much.
>
> > --
> > (:=================================:)
> >  Alvaro J. Iradier Muro - airad...@gmail.com

Reply via email to