Matt Long
Joined 6/8/2023
Matt Long said 11 months ago on Hotwire Modals :
Hey. super helpful video!! Appreciate this!! Any idea why when I render my form by directly accessing if via projects/new (e.g. not in the modal), if I click the create button, the format comes through as turbo_steam instead of HTML even though I didn't load it through the turbo controller. I just want the normal CRUD interface along with the modal capability, but when I submit my form via project#new and then project#create, it uses the turb_stream path and tries to do the replace from the turbo stream create action template rather than choosing theĀ 

format.html { redirect_to projects_path, notice: "Project was successfully created." }

in the create action. If I remove the:

format.turbo_stream

It works fine, though it is still coming through as turbo_stream fomat.

Thanks!


Matt Long said 11 months ago on Hotwire Modals :
Ok. Great! Thanks David. That worked! I just pass a parameter to the form partial used in both the _form_modal as well as my project/new and project/update views specifying whether it should use turbo. I'm assuming that's how you're suggesting I use that.

Unrelated (sort of): Do you know how I can just dismiss the modal instead of allowing it to redirect? In my case, I have loaded a form for one entity that has a link to open the form (new) for another entity that opens in the modal. When I finish creating that secondary entity, I want to update a dropdown in the first form with the new record added to it and selected. I've got the adding and selecting working. I am just not sure how to dismiss the modal after the secondary entity has been successfully created.

Thanks again for your help. This was really the only video I've watched that made sense to me. I just walked through all the steps and everything became much clearer. Nice job!