cols3=INPUT(....)
On May 26, 3:33 am, Timmie <[email protected]> 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 [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
-~----------~----~----~----~------~----~------~--~---