mercredi 20 septembre 2017

how to check the collection_radio_buttons selected for if condition? Rails

I have this form

 <div class="form-group">
      <%= f.label :status %>
        <%= f.collection_radio_buttons(:status, options_for_status, :id, :description) do |b| %>
          <div class="radio">
            <%= b.label { b.radio_button + b.value} %>                
          </div>
          <% end %>
    </div>

    if ??
    #<% f.hidden_field :data_fim, :value => Date.today %>

When the user selects a specific radiobuton, he must execute hiden_field.

STATUS = {:Aguardando => 1, :'Em atendimento' => 2, :Finalizado => 3}

These are the options present for the user, I want to set set date_fim when the user select the radio

:Finalizado => 3

Would JS be my only option? Someone to help a noob in ruby?

Aucun commentaire:

Enregistrer un commentaire