On Sat, Oct 3, 2009 at 02:52, Iceberg <iceb...@21cn.com> wrote:
>
> On Oct3, 8:41am, Renato-ES-Brazil <caliari.ren...@gmail.com> 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!

You could open a popup with a SQLFORM to create a new register in
other table, with a JavaScript/AJAX to update dropdown's options (and
select option that was created), like Djando admin do.
You could also use a "overlay" to show the form instead of the popup.
See: http://alvarojunior.com/jquery/joverlay/0.7.1/

-- 
 Álvaro Justen
 Peta5 - Telecomunicações e Software Livre
 21 3021-6001 / 9898-0141
 http://www.peta5.com.br/

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To post to this group, send email to web2py@googlegroups.com
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to