1 Replies - 1932 Views - Last Post: 15 September 2014 - 09:31 PM Rate Topic: -----

#1 joannah   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 5
  • Joined: 21-August 14

How to implement dependent drop downs in rails 4.

Posted 08 September 2014 - 01:56 AM

Hi guys,

I am trying to implement a dependent drop down in rails. I am using rails 4.1.5;There a three fields. Continent,country and district. when a user selects a continent like Afica; the second field called country should only contains countries in africa.

I have tried to look up material online and they seem to be few. I looked at this http://www.devinterf...-non-intrusivo/ .

This is what I have so far;
<% provide(:title, 'Report a case') %>
<%= render 'layouts/mainnav' %>
<%= form_for :case, url: '/case/create' do |f| %>
  <p>
    <%= f.label :continent %><br>
    <%= f.select :continent , ["Select a continent","Africa","North America","South America","Asia","Europe","Australia","Antarctica"]%>
  </p>
 
  <p>
    <%= f.label :country %><br>
    <%= f.text_field :country %>
  </p>

  <p>
    <%= f.label :district %><br>
    <%= f.text_field :district %>
  </p>
  <p>
    <%= f.label :case_category %><br>
    <%= f.select :case_category, ["Select a category of violence","Dating violence" , "Domestic and intimate partner violence" ,"Emotional abuse" , "Human trafficking", "Same-sex relationship violence" , "Sexual assault and abuse" , "Stalking" , "Violence against immigrant and refugee women" , "Violence against women at work" , "Violence against women with disabilities"]%>
  </p>
   <%= f.label :description %><br>
    <%= f.text_area :description %>
  </p>


 
  <p>
    <%= f.submit %>
  </p>
<% end %>




If someone can refer me to some material that will help me implement the dependent drop downs I will be grateful.

Is This A Good Question/Topic? 0
  • +

Replies To: How to implement dependent drop downs in rails 4.

#2 Lemur   User is offline

  • Pragmatism over Dogma
  • member icon


Reputation: 1453
  • View blog
  • Posts: 3,633
  • Joined: 28-November 09

Re: How to implement dependent drop downs in rails 4.

Posted 15 September 2014 - 09:31 PM

There's an entire Javascript section you need to add.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1