def create():
form = crud.create(
db.project,
onaccept=lambda form:
process_new_project_entry(form.vars.id), #<<<<
next = URL('index'))
return dict(form=form)
On Oct 18, 7:12 am, robmh <[email protected]> wrote:
> Hi I've just started using web2py and I need help on how to do
> something.
>
> I'm using CRUD to add an entry in db.project table as follows:
>
> def create():
> form = crud.create(
> db.project,
> next = URL('index'))
> return dict(form=form)
>
> When the new db.project entry is added -- or, for that matter, changed
> or deleted -- I want to update another table using data from the the
> new db.project entry.
>
> To put it another way, consider the following function:
>
> def process_new_project_entry(project_id)
> actions =
> extract_actions_from_project_details_field(db.project.details(project_id))
> for action in actions:
> db.action.insert( project_id = project_id, action = action)
>
> I want this function to be called when the new db.project entry is
> added.
>
> How can I do this?
>
> Thanks in advance.