-
-
Save tabishiqbal/f9696f1e1fc87445d861340d9a1550f2 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
:plain | |
var existingModal = document.querySelector("[data-controller='modal']"); | |
if (existingModal) { | |
document.body.removeChild(existingModal); | |
} | |
document.body.insertAdjacentHTML("beforeend", "#{j render partial: template.to_s}"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class CommercialPayersController < ApplicationController | |
def edit | |
render :as_modal, locals: { template: "form" } | |
end | |
def update | |
if @payer.update(payer_params) | |
redirect_to @payer, notice: "Successfully updated Commercial Payer" | |
else | |
render :as_modal, locals: { template: "form" } | |
end | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// note you could move the "modal" markup to shared template if you want | |
.modal(data-controller="modal") | |
.modal-content.w-600 | |
= form_with model: @payer do |f| | |
%h2.font-light.text-3xl.text-grey-700.mb-8 | |
Edit Payer | |
.input-group | |
= f.label :name, "Payer Name" | |
= f.text_field :name, placeholder: "Enter a name..." | |
.input-group | |
= f.label :description | |
= f.text_field :description, placeholder: "Enter a short description..." | |
.text-right | |
.btn-secondary.mr-4(data-action="click->modal#close") | |
Cancel | |
= f.submit "Save", class: "btn" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment