'Add a field to the form description.
Args:
name (unicode): The name of the field, which is the key for the value
to send back to the server.
Keyword Arguments:
label (unicode): The label for the field (e.g. "E-mail" or "Username")
field_type (unicode): The type of the field.  See `ALLOWED_TYPES` for
acceptable values.
default (unicode): The default value for the field.
placeholder (unicode): Placeholder text in the field
(e.g. "user@example.com" for an email field)
instructions (unicode): Short instructions for using the field
(e.g. "This is the email address you used when you registered.")
required (boolean): Whether the field is required or optional.
restrictions (dict): Validation restrictions for the field.
See `ALLOWED_RESTRICTIONS` for acceptable values.
options (list): For "select" fields, a list of tuples
(value, display_name) representing the options available to
the user.  `value` is the value of the field to send to the server,
and `display_name` is the name to display to the user.
If the field type is "select", you *must* provide this kwarg.
include_default_option (boolean): If True, include a "default" empty option
at the beginning of the options list.
error_messages (dict): Custom validation error messages.
Currently, the only supported key is "required" indicating
that the messages should be displayed if the user does
not provide a value for a required field.
supplementalLink (unicode): A qualified URL to provide supplemental information
for the form field. An example may be a link to documentation for creating
strong passwords.
supplementalText (unicode): The visible text for the supplemental link above.
Raises:
InvalidFieldError'

def add_field(self, name, label=u'', field_type=u'text', default=u'', placeholder=u'', instructions=u'', required=True, restrictions=None, options=None, include_default_option=False, error_messages=None, supplementalLink=u'', supplementalText=u''):

    if (field_type not in self.ALLOWED_TYPES):
        msg = u"Field    type    '{field_type}'    is    not    a    valid    type.        Allowed    types    are:    {allowed}.".format(field_type=field_type, allowed=',    '.join(self.ALLOWED_TYPES))
        raise InvalidFieldError(msg)
    field_dict = {'name': name, 'label': label, 'type': field_type, 'defaultValue': default, 'placeholder': placeholder, 'instructions': instructions, 'required': required, 'restrictions': {}, 'errorMessages': {}, 'supplementalLink': supplementalLink, 'supplementalText': supplementalText}
    field_override = self._field_overrides.get(name, {})
    if (field_type == 'select'):
        if (options is not None):
            field_dict['options'] = []
            existing_default_value = field_override.get('defaultValue')
            if include_default_option:
                field_dict['options'].append({'value': '', 'name': '--', 'default': (existing_default_value is None)})
            field_dict['options'].extend([{'value': option_value, 'name': option_name, 'default': (option_value == existing_default_value)} for (option_value, option_name) in options])
        else:
            raise InvalidFieldError('You    must    provide    options    for    a    select    field.')
    if (restrictions is not None):
        allowed_restrictions = self.ALLOWED_RESTRICTIONS.get(field_type, [])
        for (key, val) in restrictions.iteritems():
            if (key in allowed_restrictions):
                field_dict['restrictions'][key] = val
            else:
                msg = "Restriction    '{restriction}'    is    not    allowed    for    field    type    '{field_type}'".format(restriction=key, field_type=field_type)
                raise InvalidFieldError(msg)
    if (error_messages is not None):
        field_dict['errorMessages'] = error_messages
    field_dict.update(field_override)
    self.fields.append(field_dict)
