Hmmm...

Code please!

Richard


On Wed, Mar 12, 2014 at 9:56 AM, Thomas Bellembois <
[email protected]> wrote:

> Yes, I tried but it did not work either...
>
> There is something weird, actually my widget receives an integer for
> value (actually a table reference).
> I generate a checkbox <input type="checkbox" value="1234"> and then a
> span with the database entry corresponding to the value such as:
> row = db(db.table.id == value).select().first()
> I use row.label to fill in my span.
>
> The problem is, when a form is accepted an "keepvalues = True" the
> checkbox is well set to 1234 but my span can NOT be filled in because
> the "value" is to passed to my widget whereas it is for an update (when
> I use the widget to update a database entry).
>
> Thanks for your help.
>
> Thomas
>
> Le mercredi 12 mars 2014 à 09:11 -0400, Richard Vézina a écrit :
> > Ok... But did you try my suggestion? The way to set the default value
> > is the same, you just have to figure how to set it in the class, it
> > just less obvious some time.
> >
> >
> > Richard
> >
> >
> > On Wed, Mar 12, 2014 at 8:31 AM, Thomas Bellembois
> > <[email protected]> wrote:
> >         Actually I need to initialize many parameters so I took model
> >         on the
> >         AutocompleteWidget widget.
> >
> >
> >
> >         Le mardi 11 mars 2014 à 12:54 -0400, Richard Vézina a écrit :
> >         > Do you really need a class?
> >         >
> >         >
> >         > You can create widget as a simple function as shown in the
> >         book. I say
> >         > that because it easier to show you how to set default value
> >         with a
> >         > simple function (less code)...
> >         >
> >         >
> >         > def mysupercustomwidget(field, value, ...)
> >         >     ...
> >         >     if value is not None and value != '':
> >         >
> >         >         field_value = value
> >         >     INPUT(..., value=field_value)
> >         >     ...
> >         >
> >         >
> >         > Hope it helps.
> >         >
> >         >
> >         > Richard
> >         >
> >         >
> >         >
> >         >
> >         > On Tue, Mar 11, 2014 at 10:14 AM, Thomas Bellembois
> >         > <[email protected]> wrote:
> >         >         Dear web2py community,
> >         >
> >         >         I have build my own widget like:
> >         >
> >         >         class CHIMITHEQUE_MULTIPLE_widget(object):
> >         >
> >         >             def __init__(self, ..., **attributes):
> >         >                ...
> >         >
> >         >             def __call__(self, field, value):
> >         >                 ...
> >         >                 # build the widget and populate with the
> >         value
> >         >         parameter if not
> >         >         Null
> >         >                 ...
> >         >                 return DIV(...)
> >         >
> >         >         I have no problems except for the
> >         validate(keepvalues=True)
> >         >         feature, my
> >         >         widget is not populated. Actually no value is passed
> >         to the
> >         >         __call__
> >         >         function.
> >         >
> >         >         While updating a database item, the widget populates
> >         properly.
> >         >
> >         >         I do not know how exactly keepvalues works, so I may
> >         have
> >         >         missed
> >         >         something.
> >         >
> >         >         Any idea ?
> >         >
> >         >         Regards,
> >         >
> >         >         Thomas
> >         >
> >         >
> >         >
> >         >         --
> >         >         Resources:
> >         >         - http://web2py.com
> >         >         - http://web2py.com/book (Documentation)
> >         >         - http://github.com/web2py/web2py (Source code)
> >         >         - https://code.google.com/p/web2py/issues/list
> >         (Report Issues)
> >         >         ---
> >         >         You received this message because you are subscribed
> >         to the
> >         >         Google Groups "web2py-users" group.
> >         >         To unsubscribe from this group and stop receiving
> >         emails from
> >         >         it, send an email to web2py
> >         [email protected].
> >         >         For more options, visit
> >         https://groups.google.com/d/optout.
> >         >
> >         >
> >         > --
> >         > Resources:
> >         > - http://web2py.com
> >         > - http://web2py.com/book (Documentation)
> >         > - http://github.com/web2py/web2py (Source code)
> >         > - https://code.google.com/p/web2py/issues/list (Report
> >         Issues)
> >         > ---
> >         > You received this message because you are subscribed to the
> >         Google
> >         > Groups "web2py-users" group.
> >         > To unsubscribe from this group and stop receiving emails
> >         from it, send
> >         > an email to [email protected].
> >         > For more options, visit https://groups.google.com/d/optout.
> >
> >
> >
> >         --
> >         Resources:
> >         - http://web2py.com
> >         - http://web2py.com/book (Documentation)
> >         - http://github.com/web2py/web2py (Source code)
> >         - https://code.google.com/p/web2py/issues/list (Report Issues)
> >         ---
> >         You received this message because you are subscribed to the
> >         Google Groups "web2py-users" group.
> >         To unsubscribe from this group and stop receiving emails from
> >         it, send an email to [email protected].
> >         For more options, visit https://groups.google.com/d/optout.
> >
> >
> >
> > --
> > Resources:
> > - http://web2py.com
> > - http://web2py.com/book (Documentation)
> > - http://github.com/web2py/web2py (Source code)
> > - https://code.google.com/p/web2py/issues/list (Report Issues)
> > ---
> > You received this message because you are subscribed to the Google
> > Groups "web2py-users" group.
> > To unsubscribe from this group and stop receiving emails from it, send
> > an email to [email protected].
> > For more options, visit https://groups.google.com/d/optout.
>
>
>
> --
> Resources:
> - http://web2py.com
> - http://web2py.com/book (Documentation)
> - http://github.com/web2py/web2py (Source code)
> - https://code.google.com/p/web2py/issues/list (Report Issues)
> ---
> You received this message because you are subscribed to the Google Groups
> "web2py-users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> For more options, visit https://groups.google.com/d/optout.
>

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to