From 50735919c8e152762e44e8453f6a71bf940a01d2 Mon Sep 17 00:00:00 2001 From: mfo Date: Wed, 15 May 2024 14:36:52 +0200 Subject: [PATCH] fix(for_tiers): do not update for_tiers column to render the form. otherwise user could switch to dossier.for_tiers without filling mandataire required fields when he updates his identity --- .../individual_form_component.html.haml | 1 + app/controllers/users/dossiers_controller.rb | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/app/components/dossiers/individual_form_component/individual_form_component.html.haml b/app/components/dossiers/individual_form_component/individual_form_component.html.haml index 97b91976c..38a5b2b19 100644 --- a/app/components/dossiers/individual_form_component/individual_form_component.html.haml +++ b/app/components/dossiers/individual_form_component/individual_form_component.html.haml @@ -1,4 +1,5 @@ = form_for @dossier, url: update_identite_dossier_path(@dossier), html: { id: 'identite-form', class: "form", "data-controller" => "for-tiers" } do |f| + = f.hidden_field :for_tiers - if for_tiers? .fr-alert.fr-alert--info.fr-mb-2w %p.fr-notice__text diff --git a/app/controllers/users/dossiers_controller.rb b/app/controllers/users/dossiers_controller.rb index 08ecd2f55..c80792af4 100644 --- a/app/controllers/users/dossiers_controller.rb +++ b/app/controllers/users/dossiers_controller.rb @@ -139,7 +139,7 @@ module Users respond_to do |format| format.html format.turbo_stream do - @dossier.update_columns(params.require(:dossier).permit(:for_tiers).to_h) + @dossier.for_tiers = params[:dossier][:for_tiers] end end end