Error handling
Each tab PATCH is independent. Validation failures must re-open the same tab with errors — without a full page POST/redirect cycle per field.
Happy path
SettingsTabController#update runs the tab command. On :ok:
flash[:notice]— success copy- Redirect to
decidim_system.edit_organization_path(organization)with optionalanchor: "panel-toggle-<tab_id>"whendecidim_toggle_active_tabmatches a registered tab
Invalid form
On :invalid, the controller stores a payload in flash[:decidim_toggle_invalid_settings_tab]:
{
organization_id:,
tab_id:,
params: { ... submitted organization params ... },
errors: { "attribute" => ["message", ...] }
}
Redirect to the organization edit page (same anchor rules).
Replay on re-render
decidim_toggle_settings_tab_form checks that flash key. When organization_id and tab_id match the current tab:
- Rebuilds the form from stored params (not the DB model)
- Re-applies error messages on the form object
- Renders the tab with
form-errormarkup
Custom form_layout_partial: tabs must use tf.object (or fields through tf) inside decidim_toggle_settings_tab_form so replayed errors bind to inputs — see tabs/_language_tab.html.erb.
Unknown tab
PATCH …/settings_tab/<unknown> → 404.