It would probably help if you show some code, or at least explain in more 
detail an example where self submission is not possible or overly 
difficult. Note, your code can always distinguish between a form creation 
request and a form submission request by checking whether request.post_vars 
is None or whether request.env.http_method == "POST". 

As Jim suggested, if you are using SQLFORM, the easiest way to pre-populate 
is by setting field default values *before* form creation.

Anthony

On Monday, June 23, 2014 9:02:13 AM UTC-4, Graham Ranson wrote:
>
> Anthony <abastardi@...> writes: 
>
> > If your going to use the web2py FORM or SQLFORM functionality, then the 
> same code both defines and processes the form, so self submission makes 
> sense. If you would rather build all of your form creation and processing 
> code from scratch, then sure, do whatever you want. Anthony 
>
> That's the issue really - whether my design lends itself to self-submisson 
> and if not whether not using those features of web2py that are built 
> around 
> self-submission rather reduce the benefits of using web2py at all. 
> It's not that I cannot see a way to use self-submission but there are then 
> oddities - well they seem so to me - I notice that the book says: 
>
> "Pre-populating the form 
>
> It is always possible to pre-populate a form using the syntax: 
> form.vars.name = 'fieldvalue' 
>
> Statements like the one above must be inserted after the form declaration 
> and before the form is accepted, whether or not the field ("name" in the 
> example) is explicitly visualized in the form." 
>
> and to use the example from a few lines earlier: 
>
> def display_form(): 
>    record = db.person(request.args(0)) or redirect(URL('index')) 
>    url = URL('download') 
>    link = URL('list_records', args='db') 
>    form = SQLFORM(db.person, record, deletable=True, 
>                   upload=url, linkto=link) 
>
> # pre-population would go here ?! 
>
>    if form.process().accepted: 
>        response.flash = 'form accepted' 
>    elif form.errors: 
>        response.flash = 'form has errors' 
>    return dict(form=form) 
>
> in the example that I was thinking about that would involve a couple of DB 
> reads followed by the form.vars... assignments. Now if the same code is 
> then executed after submission how do these statements get handled ? I can 
> only suppose that re-executing the form=SQLFORM(...) has some magic in it, 
> but presumably not in the DB access and the form... assignments. 
> How does it deal with those ? 
>
> I've been otherwise occupied in the past few days and still haven't 
> actually done any work wit web2py yet... 
>
> graham 
>
>
>
>
>

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to