Pylons / Pylons/deform

Error messages from HiddenWidgets / Handling of compound error messages

Open
#46 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

docs enhancement needs-pr
Dominant language
JavaScript
Stars
423
Forks
158
PR merge metrics
No merged PRs in 30d

Description

I've noticed that error messages triggered by hidden fields (e.g. fields using a HiddenWidget) do not get displayed. I think the solution to this is for MappingWidget to get a custom handle_error method which will stick the messages from any hidden subfields into the mapping's error messages.

While looking into this, I noticed a second issue. Some parts of deform properly handle array-valued Invalid.msgs (see, e.g., mapping_item.pt, sequence_item.pt); other parts expect a scalar string value (e.g. mapping.pt).

I think that compound (array-valued) error messages should be allowed on any Invalid instance. To that end:

  • mapping.pt should be fixed to support compound error messages
  • Field.errormsg needs attention. My suggestion is that, in the case of compound error messages, it should return '\n'.join(msg). It should also probably be deprecated.
  • TextAreaCSVWidget.handle_error and TextInputCSVWidget.handle_error should put compound error messages in a array rather than concatenating them into a single string. (Also the example at the end of the handle_error part of the "Writing Your Own Widget" doc section should be updated.)

I'm willing to formulate this as a pull request, but I wanted to run it by you first to make sure that it all sounds reasonable.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reading MappingWidget.handle_error and the named mapping.pt, mapping_item.pt, and sequence_item.pt templates to compare scalar and compound error handling. Then inspect Field.errormsg, TextAreaCSVWidget.handle_error, and TextInputCSVWidget.handle_error, along with the Writing Your Own Widget example; done means hidden-field and array-valued messages are handled consistently across these locations.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
backend, web-dev
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.