铁轨多种形式选择 [英] rails multiple form selects

查看:194
本文介绍了铁轨多种形式选择的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个轨道形式的2个选择,其中一个取决于另一个的选定值。因此,如果每个用户有3个用户和5个项目,则一旦选择了用户,我希望项目选择只包含特定于该用户的项目。听起来很简单,但我很难做到这一点。这里是代码,而不是用户和物品我有vendor_identifier和app_identifier(所以供应商可能有很多应用程序)。非常感谢您的帮助!

I have a rails form with 2 selects where one of them depends on the the selected value of the other. So if I have 3 users and 5 items per user, once a user is selected I want the items selection to contain only the items specific to that user. Sounds pretty straightforward but I'm having a very difficult time getting this working. Here's the code where instead of users and items I have vendor_identifier and app_identifier (so a vendor may have many apps for example). Thanks very much in advance for your help!!

<p>
    <%= f.label :vendor_identifier %><br />
    <%= f.select :vendor_identifier, User.find(:all, :order => "last_name, first_name").collect {|u| [(u.first_name + " " + u.last_name), u.userid]} %>
  </p>
  <p>
    <%= f.label :app_identifier %><br />

    <%= f.select :app_identifier, App.find(:all, :conditions => {:vendor_identifier => :userid } , :order => "name") %>
  </p> 
  <p>


推荐答案

我已经编写了关于更新选择框的指南基于另一个你可能会发现有用的: http:/ /ryanbigg.com/2008/05/updating-a-select-box-based-on-otherother

I've written a guide on updating a select box based on another which you may find helpful: http://ryanbigg.com/2008/05/updating-a-select-box-based-on-another

这篇关于铁轨多种形式选择的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆