Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix question form errors not being displayed #3046

Merged
merged 12 commits into from
Mar 20, 2018

Conversation

deivid-rodriguez
Copy link
Contributor

🎩 What? Why?

The errors happening on a question form where not being properly displayed making it hard to figure out what was wrong. Now we use proper form builder methods that wrap actual models, so we get proper error messages, required attribute detection and so on.

After this PR, decidim form helper methods (to build inputs not associated to models) are no longer used anywhere in the code base. It'd be nice to get rid of them since they are quite complex and almost fully duplicate the logic of their form builder counterparts. However, I guess they can be considered public API and might be used by external plugins, so we might want to deprecate them first or not remove them at all... πŸ€·β€β™‚οΈ

πŸ“Œ Related Issues

None.

πŸ“‹ Subtasks

  • Add CHANGELOG entry

πŸ“· Screenshots (optional)

Before

before

After

after

I'll be using proper form builder helpers for the inputs of these forms
so that proper error messages can be displayed around each one. In order
to do that, each template must have different base input names to be
able to distinguish which question each answer option belongs to. So we
render a separate template next to each "add field" button, and we can
locate it from the input button itself without needing any ids.
In later commits nested templates could go through several
interpolations and the placeholder won't always be in the middle, so
stop caring about its position. This allows us to extract an utility
method since the replacement is consistently done in the same way.
For consistency with the `blank_question` method.
I think this is "more unique" and it also generates an integer, which
will be handy later.
So that the generate unique key is actually an integer. This will be
useful later when will use this id as the id for our rectify form.
Instead, create a different virtual attribute at the form level and do
proper mapping in there.
I think it reads slightly better like this.
We now use proper form builder methods that wrap actual objects, so we
get full error messages, required attribute detection, and so on.
Copy link
Contributor

@mrcasals mrcasals left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code looks good to me, and changes are perfectly explained per commit, so πŸ‘

There was a test job that failed, I've rescheduled it and see if it's green

@codecov
Copy link

codecov bot commented Mar 20, 2018

Codecov Report

Merging #3046 into master will decrease coverage by 0.05%.
The diff coverage is 98.43%.

@@            Coverage Diff             @@
##           master    #3046      +/-   ##
==========================================
- Coverage   98.67%   98.62%   -0.06%     
==========================================
  Files        1699     1699              
  Lines       40584    40602      +18     
==========================================
- Hits        40048    40042       -6     
- Misses        536      560      +24

@oriolgual oriolgual merged commit ed4fa90 into master Mar 20, 2018
@ghost ghost removed the status: WIP label Mar 20, 2018
@oriolgual oriolgual deleted the fix/no_errors_displayed_after_submission_failure branch March 20, 2018 10:46
rbngzlv added a commit that referenced this pull request Mar 21, 2018
* master:
  [RFC] Use cells for meeting m cards (#3022)
  Do not force Postgresql user to be admin when enabling trigram extension (#3053)
  Make organization reference_prefix required (#3056)
  admin can duplicate/copy meetings (#3051)
  Fix question form errors not being displayed (#3046)
  Erb whitespace cutting (#3047)
  Show debates statistics on space show and homepage (#3016)
  Fix broken translated field after form errors (#3026)
  Move decidim executable to "exe" folder (#3028)
  Friendlier buttons (#3027)
  Feedback needed after Endorsing when user has no user_groups (#2998)
  Fix seeding error on generator specs (#3021)
  fix spelling error in threshold (#3019)
  Migration plus seeds (#2933)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants