'Constructor to define the form and its elements.
@param elements: the form elements
@param attributes: form attributes'

def __init__(self, *elements, **attributes):

    self.elements = []
    append = self.elements.append
    debug = current.deployment_settings.get_base_debug()
    for element in elements:
        if (not element):
            continue
        if isinstance(element, S3SQLFormElement):
            append(element)
        elif isinstance(element, str):
            append(S3SQLField(element))
        elif isinstance(element, tuple):
            l = len(element)
            if (l > 1):
                (label, selector) = element[:2]
                widget = (element[2] if (l > 2) else DEFAULT)
            else:
                selector = element[0]
                label = widget = DEFAULT
            append(S3SQLField(selector, label=label, widget=widget))
        else:
            msg = ('Invalid    form    element:    %s' % str(element))
            if debug:
                raise SyntaxError(msg)
            else:
                current.log.error(msg)
    opts = {}
    attr = {}
    for k in attributes:
        value = attributes[k]
        if (k[:1] == '_'):
            attr[k] = value
        else:
            opts[k] = value
    self.attr = attr
    self.opts = opts
