ruby on rails - Dynamic loading of options in select menu for a form whilst using formtastic -
i have formtastic form. , problem simple. have 2 select menus. based on option selected in 1st select menu, 2nd select menu should populated. have in form code.
<% semantic_form_for @issue, :html => { :multipart => true } |form| %> <% form.inputs %> <%= form.input :department, :remote => true, :input_html => { :onchange => remote_function(:url => { :action => :get_issue_types }, :method => :get, :with => "'dep_id='+this.options[this.selectedindex].value")} %> <%= form.input :issue_type %> <% form.buttons %> <%= form.commit_button "submit" %> <% end %> <% end %>
so based on value selected department, issue type menu should correspondingly populated. remote action in controller:
def get_issue_types @issue_types = (params[:dep_id].blank?) ? [] : department.find(params[:dep_id]).issue_types.uniq end
and error get:
activerecord::recordnotfound (couldn't find issue id=get_issue_types)
how make work? thanks!
Comments
Post a Comment