'This method saves the current form'

def save_form_definition(self, trans, form_definition_current_id=None, **kwd):

    (flag, message) = self.__validate_form(**kwd)
    if (not flag):
        return (None, message)
    current_form = self.get_current_form(trans, **kwd)
    field_names_dict = {}
    for field in current_form['fields']:
        if (not field['label']):
            return (None, 'All    the    field    labels    must    be    completed.')
        if (not VALID_FIELDNAME_RE.match(field['name'])):
            return (None, ("'%s'    is    not    a    valid    field    name." % field['name']))
        if (field['name'] in field_names_dict):
            return (None, ("Each    field    name    must    be    unique    in    the    form    definition.    '%s'    is    not    unique." % field['name']))
        else:
            field_names_dict[field['name']] = 1
    if ((current_form['type'] == trans.app.model.FormDefinition.types.SAMPLE) and (not len(current_form['layout']))):
        current_form['layout'] = ['Layout1']
    form_definition = trans.app.model.FormDefinition(name=current_form['name'], desc=current_form['desc'], fields=current_form['fields'], form_definition_current=None, form_type=current_form['type'], layout=current_form['layout'])
    if form_definition_current_id:
        form_definition_current = trans.sa_session.query(trans.app.model.FormDefinitionCurrent).get(form_definition_current_id)
    else:
        form_definition_current = trans.app.model.FormDefinitionCurrent()
    form_definition.form_definition_current = form_definition_current
    form_definition_current.latest_form = form_definition
    trans.sa_session.add(form_definition_current)
    trans.sa_session.flush()
    message = ("The    new    form    named    '%s'    has    been    created.    " % form_definition.name)
    return (form_definition, message)
