On Thu, Oct 9, 2008 at 12:36 PM, mdipierro <[EMAIL PROTECTED]> wrote: > > If I understand your question, your form.load(record) would be > form.vars.update(record) >
Hi again, Sorry for the long email, it's kind of a big doubt for me. I'm pretty sure I'm doing it wrong on behalf of inexperience, so I really appreciate your help. What I'm currently trying to do is to put the value of the parent object in the new object I create. Say I have a table project that has the title and user fields (a foreign key). I stored the user_id in the session, this is what I do right now (simplified, of course): (in model:) ... db.project.description.default = "(default description)" ... (in controller:) def new_project(): f = FORM(INPUT(_name = "project_title", _type = "text")) if f.accepts(request.vars, session): db.project.insert(dict(title = f.vars.title, description = f.vars.description, user = session.user_id)) redirect(URL(r = request, f = "list")) else: return dict(form = f) My question is: is there some way of doing: ...db.insert.project(f.vars)... ? I'd be awesome if I could make "user" a hidden field directly. That'd be like: ...f = SQLFORM(db.project, hidden = [db.project.user]) f.vars.user = session.user_id... and then remove the db.project.insert line. You see, I can't put user as a default value in the model, because it changes from session to session. Right now the solution I got for using SQLFORM is to set the default, which I don't like because I may forget to reset it and add another project with the wrong user at another point: ...f = SQLFORM(db.project, fields = ["title"]) db.project.user.default = session.user_id if f.accepts(request.vars, session):... There'a also Tim's solution, which is to replicate the form in the view with the correct hidden field and create a "bogus" SQLFORM for the accepts. The other problem I ran into is I'd like to a "Back" button on the forms, which forces me to go Tim's solution and manually an input tag and a "value='{{=form.field}}'" attribute for each field on the edit_project form. So, what would be the "correct" way to do it ? By the way, I just started on it but I just love it so far. The ORM is the coolest ever and, although I'm aware there are more comprehensive templating engines, I just love the simplicity of web2py's. Overall it sometimes feels like Rails yet it has a way greater deal of finesse into it. Thanks, Deodoro Filho --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "web2py Web Framework" group. To post to this group, send email to web2py@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/web2py?hl=en -~----------~----~----~----~------~----~------~--~---