samedi 23 mai 2015

Explain how the Radio button works for form_for?

Please suggest its proper syntax I want that user should be either male or female I am not able to find out its proper use.

This is my form, on clicking the radio buttons both are selected and it stays selected. I want that user should choose either male or female.

<%= form_for @user do |f| %>  
      <div class="well-lg">
      <h4>Personal Details</h4>
      <div class="form-group">
        <%= f.label :First_Name %><br />
         <%= f.text_field :fname, :class=> 'form-control' %>
      </div>
      <div class="form-group">
        <%= f.label :Last_Name %><br />
        <%= f.text_field :lname, :class=> 'form-control' %>
      </div>
      <div class="form-group">
        <%= f.label :Email_Address %><br />
        <%= f.text_field :email, :class=> 'form-control' %>
      </div>
      <div class="form-group">
        <%= f.label :Mobile_No%><br />
        <%= f.text_field :mob, :class=> 'form-control' %>
      </div>
      <div class="form-group">
        <%= f.label :Gender %> <br />
        <%= f.label :Gender, 'male' %>
        <%= f.radio_button :gender_male, 'male' %>
        <%= f.label :Gender, 'female' %>
        <%= f.radio_button :gender_female, 'female' %><br />
      </div>
      <div class="form-group">
        <%= f.label :Country %><br />
        <%= f.text_field :country, :class=> 'form-control' %>
      </div>
      <div class="form-group">
        <%= f.label :State %><br />
        <%= f.text_field :state, :class=> 'form-control'  %>
      </div>
      <div class="form-group">
        <%= f.label :Suburb %><br />
        <%= f.text_field :suburb, :class=> 'form-control'  %>
      </div>
      <div class="form-group">
        <%= f.label :Postal_Code %><br />
        <%= f.text_field :postal, :class=> 'form-control'  %>
      </div>
      <div class="form-group">
        <%= f.label :Address %><br />
        <%= f.text_area :add, :class=> 'form-control' %>
      </div>
      <div class="button">
        <%= f.submit "Next" %>
      </div>
    </div>
<% end %>

Pls help me on this

Aucun commentaire:

Enregistrer un commentaire