خرید بک لینک

Vote count: 0

Using the simple form gem for Ruby on Rails, I have a form that looks like this:

<%= simple_form_for(article, html: {class: 'form-vertical'}) do |f| %>
...
<div class="field">
<%= f.collection_select :category_id, Category.all, :id, :name, {prompt: "Choose a category"} %>
<%= f.collection_select :subcategory_id, Subcategory.all, :id, :name, {prompt: "Choose a subcategory"} %>
<%= f.input :title %>
<%= f.input :content, input_html: { rows: 20 }%>
</div>

<div class="actions">
<%= f.submit %>
</div>
<% end %>

Is there a way to base the options in the subcategory input on the selection in the category input? What I mean is, if I had a category "food", then I would be able to pick a subcategory "apple", but not "table". Would this be possible?

asked 37 secs ago

- - , .
.

برچسب: نویسنده: استخدام کار تاريخ: چهارشنبه 23 تير 1395 ساعت: 0:39

صفحه بندی