I have a form that has a dropdown at the top which looks like the following
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>
I want to pull the already existing attributes from the selected field into the form and make it possible for the user to update them via textboxes. I can't quite find what I'm looking for via select 2 documentation. What's the best way to do it simply in rails using the controller/js?
Controller looks like the following:
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
And the rest should just populate dynamically based on this selection.
Can you try like this:
@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%" ) %>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.