you can do something like

class MyWidget:
    def __init__(self,**parameters):
         self.parameters=parameters
    def __call__(self,field,value):
         # use self.parameters
         return INPUT(_type='text',_name=field.name,_value=value)

db.table.field.widget=MyWidget(parameter1="1",parameter2="2")

On Oct 5, 7:44 pm, Renato-ES-Brazil <caliari.ren...@gmail.com> wrote:
> I am here trying to create a custom widget, inside a class that
> extends SQLFORM, but how could I create a custom widget that allow me
> to send others parameters besides "field" and "value"?
>
> I would like call the new widget by sending the parameters "control"
> and "function". So, inside the function, I would use the values to
> create properly the "add" link (url).
>
> I found only a few examples of customization of widget.
>
> Thanks.
>
> On Oct 5, 8:03 am, Renato-ES-Brazil <caliari.ren...@gmail.com> wrote:
>
> > Cool!
>
> > Before I try to do something I really wanted to know if there was
> > something done by passing a parameter.
>
> > Thanks a lot guys!
>
> > On Oct 5, 1:08 am, mdipierro <mdipie...@cs.depaul.edu> wrote:
>
> > > It would be nice to a widget that does this.
>
> > > On Oct 4, 10:14 pm, Álvaro Justen [Turicas] <alvarojus...@gmail.com>
> > > wrote:
>
> > > > 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