2017-09-18 25 views
0

我有了在它看起來像下面選擇二填充更新表單上的其他字段鋼軌

HTML頂部的下拉列表形式

<div class="form-group"> 
     <label for="psr" class="col-sm-2 col-form-label">PSR</label> 
     <div class="col-lg-10"> 
     <%= select_tag(:psr, options_for_select(@psr), class:'form-control remote-select', include_blank: true, style:"width:50%") %> 
     </div> 
    </div> 

我想拉從選定的現有屬性字段轉換爲表單並使用戶可以通過文本框更新它們。我無法通過選擇2文檔找到我正在尋找的內容。簡單地使用控制器/ js在rails中執行它的最佳方法是什麼?

控制器如下所示:

def index 
    @psr = {} 
    CircuitVw.where("activity_ind IN ('Pending', 'In Progress')").order("document_number DESC").each do | circuit | 
     @psr[ "#{circuit.psr} - #{circuit.customer_name}" ] = circuit.psr 
    end 

而其餘的應該只是動態填充在此基礎上選擇。

回答

0

你可以嘗試這樣的:

@psr =CircuitVw.where("activity_ind IN ('Pending', 'In Progress')").order("document_number DESC") 
<%= select_tag(:psr, options_from_collection_for_select(@psr, 'id', 'customer_name'), class:'form-control remote-select', include_blank: true, style:"width:50%") %> 
相關問題