On Oct3, 8:41am, Renato-ES-Brazil <[email protected]> wrote:
> Hi guys!
>
> When the form displays the select with several options from the other
> table, using the "is_in_db" configuration, couldn't also to put a
> button, for example "ADD NOW", next to it to allows add a new option?
>
> Currently is there this possibility for the CRUD (create and update
> forms)?
I've been in same situation as you mentioned. Here is my journey.
Adding a "Add Now" button is easy. You can either customize the form,
or customize the widget, or just use some jquery effect in a way like
this:
def youraction():
form=crud.create(...)
...
return dict(form=DIV(
form,
SCRIPT('''$(document).ready(function() {
$("#your_widgit_id").after(
"<a target='_blank' href='/yourapp/default/addnow'>Add Now</
a>");
});'''),
))
However, I found that after successfully adding a new entry into db,
there is no obvious way to refresh the is_in_db field itself,
providing that I don't want to HARDCODE one more dedicated ajax action
in my already-too-complex controller.
So, my user still have to refresh the whole original page to see the
change after "add now", with a price of losing all his previous input.
Lucky enough that I could arrange the is_in_db field at the first line
of my form, so the waste of input is minimum. In this case, the
benefit of "Add Now" button is not as big as we thought.
If anybody knows a better solution, please give me some tips. Thanks!
Sincerely,
Iceberg
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"web2py-users" group.
To post to this group, send email to [email protected]
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
-~----------~----~----~----~------~----~------~--~---