You can set default values for db Fields, do it before the form creation db.table.field.default = "Bla Bla Bla" form = SQLFORM(db.table)
On 10/4/11, Luca <luca.de.alf...@gmail.com> wrote: > I need to have a form generated via SQLFORM where the initial values of the > fields are pre-filled with dynamically generated content. > What I am trying is (suppose I have a table mytable with title and content > as fields): > > form = SQLFORM(db.mytable) > > form.vars.title = "my title" > > form.vars.content = "my content" > > if form.accepts(request.post_vars, session): > > <some code> > > return dict(form=form) > > > Yet, if I do this, I get an error that says: > > <type 'exceptions.SyntaxError'>(No fields to update) > > So, how can one define dynamically the values that appear initially in a > SQLFORM? > I know that I can define defaults in the models definition, but I want to do > it dynamically. > > What is the way to do it? And why do I get the above error? > > Many thanks, > > Luca > > > > > > > > > > -- -- Bruno Rocha [ About me: http://zerp.ly/rochacbruno ] [ Aprenda a programar: http://CursoDePython.com.br ] [ O seu aliado nos cuidados com os animais: http://AnimalSystem.com.br ] [ Consultoria em desenvolvimento web: http://www.blouweb.com ]