'Widget method for this form element. Renders a table with
checkboxes for all available options.
This widget uses s3.inline_component.js to facilitate
manipulation of the entries.
@param field: the Field for this form element
@param value: the current value for this field
@param attributes: keyword attributes for this widget
@ToDo: Add ability to add new options to the list
@ToDo: Option for Grouped Checkboxes (e.g. for Activity Types)'

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

    opts = self.options
    if (opts.readonly is True):
        return self.represent(value)
    if (value is None):
        value = field.default
    if isinstance(value, basestring):
        data = json.loads(value)
    else:
        data = value
        value = json.dumps(value, separators=SEPARATORS)
    if (data is None):
        raise SyntaxError('No    resource    structure    information')
    T = current.T
    script = opts.get('script', None)
    if script:
        current.response.s3.jquery_ready.append(script)
    options = self._options(data)
    formname = self._formname()
    fieldname = data['field']
    field_name = ('%s-%s' % (formname, fieldname))
    if (not options):
        widget = T('No    options    currently    available')
    else:
        translate = opts.get('translate', None)
        if (translate is None):
            s3db = current.s3db
            if hasattr(s3db, fieldname):
                reusable_field = s3db.get(fieldname)
                if reusable_field:
                    represent = reusable_field.attr.represent
                    if hasattr(represent, 'translate'):
                        translate = represent.translate
        cols = opts.get('cols', 1)
        count = len(options)
        num_of_rows = (count / cols)
        if (count % cols):
            num_of_rows += 1
        table = [[] for row in range(num_of_rows)]
        row_index = 0
        col_index = 0
        for _id in options:
            input_id = ('id-%s-%s-%s' % (field_name, row_index, col_index))
            option = options[_id]
            v = option['name']
            if translate:
                v = T(v)
            label = LABEL(v, _for=input_id)
            title = option.get('help', None)
            if title:
                label['_title'] = title
            widget = TD(INPUT(_disabled=(not option['editable']), _id=input_id, _name=field_name, _type='checkbox', _value=_id, hideerror=True, value=option['selected']), label)
            table[row_index].append(widget)
            row_index += 1
            if (row_index >= num_of_rows):
                row_index = 0
                col_index += 1
        widget = TABLE(table, _class='checkboxes-widget-s3')
    real_input = ('%s_%s' % (self.resource.tablename, field_name))
    default = dict(_type='text', _value=value, requires=(lambda v: (v, None)))
    attr = StringWidget._attributes(field, default, **attributes)
    attr['_class'] = (attr['_class'] + '    hide')
    attr['_id'] = real_input
    output = DIV(INPUT(**attr), widget, _id=self._formname(separator='-'), _field=real_input, _class='inline-checkbox    inline-component', _name=('%s_widget' % field_name))
    return output
