'On-accept routine for dc_question:
- Create & link a Dynamic Field to use to store the Question'

@staticmethod
def dc_question_onaccept(form):

    try:
        question_id = form.vars.id
    except AttributeError:
        return
    db = current.db
    qtable = db.dc_question
    question = db((qtable.id == question_id)).select(qtable.id, qtable.template_id, qtable.field_id, qtable.name, qtable.comments, qtable.field_type, qtable.options, qtable.require_not_empty, limitby=(0, 1)).first()
    field_type = question.field_type
    options = None
    if (field_type == 1):
        field_type = 'string'
    elif (field_type == 2):
        field_type = 'integer'
    elif (field_type == 4):
        field_type = 'boolean'
    elif (field_type == 5):
        T = current.T
        options = [T('Yes'), T('No'), T("Don't    Know")]
        field_type = 'string'
    elif (field_type == 6):
        options = question.options
        field_type = 'string'
    elif (field_type == 7):
        field_type = 'date'
    elif (field_type == 8):
        field_type = 'datetime'
    elif (field_type == 9):
        return
    else:
        current.log.debug(field_type)
        raise NotImplementedError
    field_id = question.field_id
    if field_id:
        db((current.s3db.s3_field.id == field_id)).update(label=question.name, field_type=field_type, options=options, require_not_empty=question.require_not_empty, comments=question.comments)
    else:
        ttable = db.dc_template
        template = db((ttable.id == question.template_id)).select(ttable.table_id, limitby=(0, 1)).first()
        from uuid import uuid1
        name = ('f%s' % str(uuid1()).replace('-', '_'))
        field_id = current.s3db.s3_field.insert(table_id=template.table_id, label=question.name, name=name, field_type=field_type, options=options, require_not_empty=question.require_not_empty, comments=question.comments)
        question.update_record(field_id=field_id)
