What about

return DIV(TAG[''](*opts, **attr))



Il giorno giovedì 23 gennaio 2014 19:45:20 UTC+1, Annet ha scritto:
>
> I have the following custom checkboxes widget:
>
>
> def bs3checkboxeswidget(field, value, **attributes):
>
>     if isinstance(value, (list, tuple)):
>         values = [str(v) for v in value]
>     else:
>         values = [str(value)]
>
>     attr = OptionsWidget._attributes(field, {}, **attributes)
>     attr['_class'] = attr.get('_class', 'web2py_checkboxeswidget')
>
>     requires = field.requires
>     if not isinstance(requires, (list, tuple)):
>         requires = [requires]
>     if requires and hasattr(requires[0], 'options'):
>         options = requires[0].options()
>     else:
>         raise SyntaxError('widget cannot determine options of %s'
>                               % field)
>
>     options = [(k, v) for k, v in options if k != '']
>     opts = []
>
>     for k, v in options:
>         if k in values:
>             r_value = k
>         else:
>             r_value = []
>         opts.append(LABEL(v, INPUT(_type='checkbox',
>                                _id='%s%s' % (field.name, k),
>                                _name=field.name,
>                                requires=attr.get('requires', None),
>                                hideerror=True, _value=k,
>                                value=r_value),
>                          _for='%s%s' % (field.name, k)))
>
>     if opts:
>         opts.append(
>             INPUT(requires=attr.get('requires', None),
>                   _style="display:none;",
>                   _disabled="disabled",
>                   _name=field.name,
>                   hideerror=False))
>
>     return TAG[''](*opts, **attr)
>
>
> It generates:
>
> <label>
>     opening_hours
>     <input type="checkbox" ... >
> </label>
> <label>
>     event_list
>     <input type="checkbox" ... >
> </label>
> <label>
>     timetable
>     <input type="checkbox" ... >
> </label>
>
> I want this to be enclosed by a div
>
> <div class="checkbox">
> <label>
>     opening_hours
>     <input type="checkbox" ... >
> </label>
> <label>
>     event_list
>     <input type="checkbox" ... >
> </label>
> <label>
>     timetable
>     <input type="checkbox" ... >
> </label>
> </div>
>
> How do I code this?
>
>
> Kind regards,
>
> Annet
>

-- 
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/groups/opt_out.

Reply via email to