Skip to content

Commit

Permalink
new_authorization_request_hidden_params is now responsible for checki…
Browse files Browse the repository at this point in the history
…ng persistence and attributes presence
  • Loading branch information
JeSuisUnCaillou committed Dec 3, 2024
1 parent 9f831bc commit 4a56cf3
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 7 deletions.
7 changes: 6 additions & 1 deletion app/helpers/authorization_requests_helpers.rb
Original file line number Diff line number Diff line change
@@ -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)
Expand Down
2 changes: 1 addition & 1 deletion app/views/authorization_request_forms/_form.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -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 } %>
</div>

<% if content_for? :sticky_bar %>
Expand Down
Original file line number Diff line number Diff line change
@@ -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 %>
<% new_authorization_request_hidden_params[:attributes].each do |key, value| %>
<%= f.hidden_field key, value: %>
<% end %>

0 comments on commit 4a56cf3

Please sign in to comment.