Timmie,

I see a workaround in ColdFusion that is the following:

1/ SELECT statement, INPUT statement and some Javascript. Javascript
function hides the INPUT in an appropriately wrapped DIV.
2/ In the SELECT include 'Other' as part of your OPTION list.
3/ If 'Other' is selected then the DIV/INPUT pair is displayed for the
user to input a new item. Database update occurs.

Not as elegant as a combo box but it works.

On May 26, 3:33 am, Timmie <timmichel...@gmx-topmail.de> wrote:
> > you can do
>
> > class OptionsWidget:
>
> >     @staticmethod
> >     def has_options(field):
> >         return hasattr(field.requires, 'options')\
> >              or isinstance(field.requires, IS_NULL_OR)\
> >              and hasattr(field.requires.other, 'options')
>
> >     @staticmethod
> >     def widget(field, value):
> >         id = '%s_%s' % (field._tablename, field.name)
> >         if isinstance(field.requires, IS_NULL_OR)\
> >              and hasattr(field.requires.other, 'options'):
> >             opts = [OPTION(_value='')]
> >             options = field.requires[1].other.options()
> >         elif hasattr(field.requires, 'options'):
> >             opts = []
> >             options = field.requires.options()
> >         else:
> >             raise SyntaxError, 'widget cannot determine options of %s'
> > % field
> >         opts += [OPTION(v, _value=k) for (k, v) in options]
> >         return SELECT(*opts, **dict(_id=id, _class=field.type,
> >                       _name=field.name, value=value,
> >                       requires=field.requires))
>
> > db.mytest.person.widget=OptionWidget.widget
>
> Thanks for this example code.
>
> As it works not out of the box with my table, I would need to play a
> bit with it.
>
> I think this is a faily common thing:
> For instance these forms:
> "where did you hear from us?":
> Search engine, friends, newspaper, others => please 
> specifyhttp://support.easywebstore.net/index.php?_m=knowledgebase&_a=viewart...
>
> What about a workaroud to place a field in col3 when a user selects
> "other" or "Enter New Item" where the input can be typed in?
>
> Pseudocode:
> <select>
>   <option value="volvo">Volvo</option>
>   <option value="saab">Saab</option>
>   <option value="mercedes">Mercedes</option>
>   <option value="new_value">Enter New Item</option>   => specify:
> <input>mynewcar</input>
> </select>
>
> The problem is how to sync these two forms.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"web2py Web Framework" 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