demarches-normaliennes/app/controllers/prefill_descriptions_controller.rb
Sébastien Carceles 1a72b80f8f
fix: "remove" a champ to prefill (#8612)
* fix: "remove" a champ to prefill

Removing a champ to prefill on /preremplir used to fail, because of a
collusion (having the same form multiple times on un page looks like a
bad idea, when it comes to multiple input fields).

* fix specs
2023-02-13 08:17:22 +00:00

30 lines
678 B
Ruby

class PrefillDescriptionsController < ApplicationController
before_action :retrieve_procedure
before_action :set_prefill_description
def edit
end
def update
@prefill_description.update(prefill_description_params)
respond_to do |format|
format.turbo_stream
format.html { render :edit }
end
end
private
def retrieve_procedure
@procedure = Procedure.publiees_ou_brouillons.opendata.find_by!(path: params[:path])
end
def set_prefill_description
@prefill_description = PrefillDescription.new(@procedure)
end
def prefill_description_params
params.require(:type_de_champ).permit(:selected_type_de_champ_ids)
end
end