'Render this widget
@param field: the Field
@param value: the currently selected value(s)
@param attributes: HTML attributes for the widget'

def __call__(self, field, value, **attributes):

    fieldname = field.name
    attr = Storage(attributes)
    if ('_id' in attr):
        _id = attr.pop('_id')
    else:
        _id = ('%s-options' % fieldname)
    attr['_id'] = _id
    if ('_name' not in attr):
        attr['_name'] = fieldname
    options = self._options(field, value)
    if self.multiple:
        attr['_multiple'] = 'multiple'
    widget = SELECT(**attr)
    if ('empty' not in options):
        groups = options['groups']
        append = widget.append
        render_group = self._render_group
        for group in groups:
            options = render_group(group)
            for option in options:
                append(option)
    widget.add_class('groupedopts-widget')
    widget_opts = {'columns': self.cols, 'emptyText': s3_str(current.T('No    options    available')), 'orientation': (self.orientation or 'columns'), 'sort': self.sort, 'table': self.table}
    script = ("$('#%s').groupedopts(%s)" % (_id, json.dumps(widget_opts, separators=SEPARATORS)))
    jquery_ready = current.response.s3.jquery_ready
    if (script not in jquery_ready):
        jquery_ready.append(script)
    return widget
