Thanks, that's a start, but how now do I get 'uuid' which I've set as
a default field in the model. Is there a way I can manually set the
value in the controller before invoking form.accepts? Simplest I can
think of is:
value = computevalue()
db.table.field.default = lambda: value # effectively manually set
field to value
if form.accepts(request.vars, session):
redirect(URL('bla', args={'value': value}))
This way I have the field value so I can pass it on in the redirect.
A bit odd, and I also don't like how I end up computing the value even
when the form doesn't get accepted. So I'm wondering if there's a more
direct way.
BTW, is there any effective difference here if I use compute instead
of default? Is the only real difference between the two that compute
receives the other fields as a dict? In this dict passed to compute,
are fields set by default included while compute fields are not? I
guess with no guarantee is made about the order in which compute
functions are invoked, so we can't add the computed field to this dict
and expect it to be seen by other compute fields, right?
On Mar 26, 5:09 pm, DenesL <[email protected]> wrote:
> The new record id will be in form.vars.id after the accepts.
>
> On Mar 26, 7:46 pm, Brian Will <[email protected]> wrote:
>
>
>
>
>
>
>
> > When using SQLFORM, I'd like to get the default/computed values of
> > fields not included in the form. Can I do this without making another
> > query? Can I get, say, the autogen'd id of the new record? For
> > example:
>
> > form = SQLFORM(db.job_post, submit_button='Post Job',
> > formstyle='table2cols',
> > fields=['poster_name', 'poster_email', 'poster_phone',
> > 'zipcode', 'location_description', 'job_type', 'job_title',
> > 'job_description'],
> > _id='postjob'
> > )
> > if form.accepts(request.vars, session):
> > # ...
>
> > I want the 'id' and 'uuid' field values created when this form
> > accepts. To be honest, I'm not even sure how to do this with a query
> > except by matching on all provided fields (because none of the other
> > fields are unique), and that just feels ugly.
>
> > Should I have to resort to a manual FORM in this instance?
>
> > Thanks.