From 4a56cf389df76389aed89668082d90b0eca6dd40 Mon Sep 17 00:00:00 2001 From: Caillou <6117264+JeSuisUnCaillou@users.noreply.github.com> Date: Tue, 3 Dec 2024 13:50:24 +0100 Subject: [PATCH] new_authorization_request_hidden_params is now responsible for checking persistence and attributes presence --- app/helpers/authorization_requests_helpers.rb | 7 ++++++- app/views/authorization_request_forms/_form.html.erb | 2 +- .../shared/_hidden_params.html.erb | 8 +++----- 3 files changed, 10 insertions(+), 7 deletions(-) diff --git a/app/helpers/authorization_requests_helpers.rb b/app/helpers/authorization_requests_helpers.rb index 02ccd925b..48b5f4f6e 100644 --- a/app/helpers/authorization_requests_helpers.rb +++ b/app/helpers/authorization_requests_helpers.rb @@ -1,7 +1,12 @@ module AuthorizationRequestsHelpers + # rubocop:disable Rails/HelperInstanceVariable def new_authorization_request_hidden_params - params.slice(:attributes).permit! + return {} if @authorization_request.persisted? + + permitted_params = params.slice(:attributes).permit! + permitted_params[:attributes] end + # rubocop:enable Rails/HelperInstanceVariable def start_authorization_request_form(form, disabled: false) text = t('start_authorization_request_form.cta', authorization_name: form.authorization_definition.name) diff --git a/app/views/authorization_request_forms/_form.html.erb b/app/views/authorization_request_forms/_form.html.erb index f5bb35966..7763c11ea 100644 --- a/app/views/authorization_request_forms/_form.html.erb +++ b/app/views/authorization_request_forms/_form.html.erb @@ -18,7 +18,7 @@ <%= yield %> - <%= render partial: "authorization_request_forms/shared/hidden_params", locals: { f: f } unless @authorization_request.persisted? %> + <%= render partial: "authorization_request_forms/shared/hidden_params", locals: { f: f } %> <% if content_for? :sticky_bar %> diff --git a/app/views/authorization_request_forms/shared/_hidden_params.html.erb b/app/views/authorization_request_forms/shared/_hidden_params.html.erb index 72ba58550..70fac6375 100644 --- a/app/views/authorization_request_forms/shared/_hidden_params.html.erb +++ b/app/views/authorization_request_forms/shared/_hidden_params.html.erb @@ -1,5 +1,3 @@ -<% if new_authorization_request_hidden_params.present? && new_authorization_request_hidden_params[:attributes].present? %> - <% new_authorization_request_hidden_params[:attributes].each do |key, value| %> - <%= f.hidden_field key, value: %> - <% end %> -<% end %> \ No newline at end of file +<% new_authorization_request_hidden_params[:attributes].each do |key, value| %> + <%= f.hidden_field key, value: %> +<% end %>