Search code examples
ruby-on-railsformsshopify-app

Display the value of a field in a form with rails


I am able to display a form in a modal window doing this:

index.html.erb

 <a href="#" onclick="newModal('<%= form_edit_url %>','Title')">Edit</a>

And it works.

Now I want to make an edit link. It will display the same form with the fields that were previously filled.

I send params to the controller with:

            <li><%= link_to 'edit', edit_path(address.attributes) %></li>

But it doesn't display the form in a modal window...

How can I do this?


Solution

  • It might better to have you modal content as a partial that you render in the modal. $("#shared-modal").html("<%= render('new_modal', locals: {zone: @zone})) %>";

    To have your fields fill out again you would need to write some JS in the modal that will find those values and duplicate them into your new form fields.