Show errors outside of the upload modal#15981
Conversation
📝 WalkthroughWalkthroughPrevents validation error messages from being rendered inside file upload modals by adding a hidden validation input to the modal and moving the error-element composition to the form builder, linking errors to the main form via a data attribute. Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (1 warning, 1 inconclusive)
✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Pull request overview
This change ensures that validation errors related to upload fields (e.g., “cannot be blank”) are rendered outside the upload modal in the main form area, so admins can see and act on them without needing the modal open. It also aligns the upload field’s HTML5 validation wiring (hidden checkbox + error span) with Foundation Abide’s expectations and adds tests around these behaviors.
Changes:
- Updated
Decidim::FormBuilder#uploadto appenderror_and_help_textand anabide_error_elementlinked to a hidden validation field, so errors render outside the modal and hook correctly into Foundation Abide. - Refactored
Decidim::UploadModalCell#input_validation_fieldto only emit the hidden checkbox (no error/help markup), and added an explicitvalidation_field_idused by the form builder. - Added RSpec coverage for upload builder error/help text rendering and for the upload modal cell’s hidden validation checkbox, ID, and absence of errors/help-text inside the modal.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| decidim-core/lib/decidim/form_builder.rb | Extends #upload to render error/help text and a Foundation Abide error span outside the modal; enhances abide_error_element to accept a :for option and wire data-form-error-for to the hidden validation field. |
| decidim-core/app/cells/decidim/upload_modal_cell.rb | Simplifies input_validation_field to a hidden checkbox with a stable id (attribute_validation) and documents that validation errors now display in the main form area instead of inside the modal. |
| decidim-core/spec/lib/form_builder_spec.rb | Adds tests ensuring upload error messages and help text are rendered (and localized) after the upload cell, and that required upload fields get an HTML5 error element bound to the validation field’s ID. |
| decidim-core/spec/cells/decidim/upload_modal_cell_spec.rb | Adds tests verifying the required-field hidden checkbox’s ID for Abide, the required indicator, and that no .form-error or .help-text appear inside the upload modal itself. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
|
This is ready for your review @alecslupu |
🎩 What? Why?
Related to the changes that I'm proposing at #15980, if there's an error in the form related to the modal, this error isn't shown.
📌 Related Issues
Testing
📷 Screenshots
Before
After
Summary by CodeRabbit