jeudi 23 août 2018

how to handle a submit with two different forms or methods

I have a checkbox outside a form and for this to work I use the form with an id, like this:

My form with the id:'check-form'

<%= form_for(:execution, url:{controller:"executions", action:'create_multiple'}, html:{id:"check-form", class:"form-inline"}) do |form| %>
    <div class="input-group mb-3">
        <%= form.select :collaborator_id,@collaborators.collect 
           { |collaborator| [collaborator.name, collaborator.id] },
           {prompt: 'Selecione'}, {class:'form-control', required:true} %>
        <div class="input-group-append">
            <%= button_tag(type: "submit", class: "btn btn-raised btn-primary", form:'check-form') do %>
                <span><i class="far fa-play-circle"></i> Play</span>
            <% end %>
        </div>
    </div>
<% end %>

My checkbox with form:'check-form'

<%= check_box_tag 'execution[status_id][]', item.sector_status(sector.id).id, checked:false, 
{id:"check-#{item.sector_status(sector.id).id}", form:'check-form'}%>

What I want is to be able to use the value of the checkbox in another form with another method. Is there any way I could do this or maybe use a function to make the form "work" with two possible methods?




Aucun commentaire:

Enregistrer un commentaire