'Render/process the form.
@param request: the S3Request
@param resource: the target S3Resource
@param record_id: the record ID
@param readonly: render the form read-only
@param message: message upon successful form submission
@param format: data format extension (for audit)
@param options: keyword options for the form
@todo: describe keyword arguments
@return: a FORM instance'

def __call__(self, request=None, resource=None, record_id=None, readonly=False, message='Record    created/updated', format=None, **options):

    if (resource is None):
        self.resource = request.resource
        (self.prefix, self.name, self.table, self.tablename) = request.target()
    else:
        self.resource = resource
        self.prefix = resource.prefix
        self.name = resource.name
        self.tablename = resource.tablename
        self.table = resource.table
    response = current.response
    s3 = response.s3
    settings = s3.crud
    prefix = self.prefix
    name = self.name
    tablename = self.tablename
    table = self.table
    record = None
    labels = None
    self.record_id = record_id
    if (not readonly):
        _get = options.get
        if (record_id is None):
            data = _get('data', None)
            from_table = _get('from_table', None)
            from_record = _get('from_record', None)
            map_fields = _get('map_fields', None)
            record = self.prepopulate(from_table=from_table, from_record=from_record, map_fields=map_fields, data=data, format=format)
        self.record_id = record_id = self.deduplicate_link(request, record_id)
        mark_required = self._config('mark_required', default=[])
        (labels, required) = s3_mark_required(table, mark_required)
        if required:
            s3.has_required = True
        else:
            s3.has_required = False
    if (format == 'plain'):
        formstyle = 'table3cols'
    elif readonly:
        formstyle = settings.formstyle_read
    else:
        formstyle = settings.formstyle
    buttons = self._submit_buttons(readonly)
    if (record is None):
        record = record_id
    response.form_label_separator = ''
    form = SQLFORM(table, record=record, record_id=record_id, readonly=readonly, comments=(not readonly), deletable=False, showid=False, upload=s3.download_url, labels=labels, formstyle=formstyle, separator='', submit_button=settings.submit_button, buttons=buttons)
    if (settings.submit_style and (not settings.custom_submit)):
        try:
            form[0][(-1)][0][0]['_class'] = settings.submit_style
        except:
            pass
    subheadings = options.get('subheadings', None)
    if subheadings:
        self._insert_subheadings(form, tablename, formstyle, subheadings)
    logged = False
    if (not readonly):
        link = _get('link')
        hierarchy = _get('hierarchy')
        onvalidation = _get('onvalidation')
        onaccept = _get('onaccept')
        (success, error) = self.process(form, request.post_vars, onvalidation=onvalidation, onaccept=onaccept, hierarchy=hierarchy, link=link, http=request.http, format=format)
        if success:
            response.confirmation = message
            logged = True
        elif error:
            response.error = error
    if ((not logged) and (not form.errors)):
        current.audit('read', prefix, name, record=record_id, representation=format)
    return form
