def format_form_errors(form):
    """Formats form errors in HTML
    if there is only one error - returns a plain string
    if more than one, returns an unordered list of errors
    in HTML format.
    If there are no errors, returns empty string
    """
    if form.errors:
        errors = form.errors.values()
        if len(errors) == 1:
            return errors[0]
        else:
            result = '<ul>'
            for error in errors:
                result += '<li>%s</li>' % error
            result += '</ul>'
            return result
    else:
        return ''
