Issue #5 new

errors_for() seems buggy

Anonymous created an issue

When you use the example of the last version of pyramid_simpleform (0.7) and you make a mistake in a form, it outputs wrong error messages.

I think that the method errors_for() of pyramid_simpleform.renderers.Renderer is buggy. It must return something like:

return [self.errors[name]] if name in self.errors else None

Patrick

Comments (2)

  1. Anonymous

    This is broken because of two peices of code.

    1) line 139 renderers name is passed to def errors_for(self, name): however it is not used and the def return self.errors this should return self.errors[name]

    2) line 165 same file if there is only one error returned from errors_for you will get a li item for each character in the error. IE: required becomes

    1. r
    2. e
    3. q
    4. u
    5. i
    6. r
    7. e
    8. d
  2. Anonymous

    Change line 139 to return self.errors[name]

    Change line 165 from content = "\n".join(HTML.tag("li", error) for error in errors) to

    if isinstance(errors, basestring):
        content = HTML.tag("li", errors)
    else:
        content = "\n".join(HTML.tag("li", error) for error in errors)
    
  3. Log in to comment