I'm trying to create a form with two buttons. One would be the submit button, but I would also like to have a second button that would allow creating a required element of the form if it does not exist already.
Something like this:
<%= simple_form_for @class do |f| %>
<%= f.input :title %>
<%= f.association :teacher %>
<%= f.button :new_teacher, new_teacher_path, "Add a Teacher" %>
<%= f.button :submit %>
<% end %>
What I want to happen when the :new_teacher button is clicked is for the new teacher view to open, the user would then fill that out, submit it, and return to creating the class. Is there a sane way to do this?
This is mostly a design issue, it feels like the button should be "within" the form, so that if the user runs into a missing item while filling out the form s/he can easily create it.
Teacherbelongs to classClass?Classbelongs_to classTeacher.