ruby on rails - how to use check box with additional textbox -


i have multiple check box in form ,working good.i need give more option add 4 chkbox text field related them

my model looks like

paymentgateway.rb

has_many :payment_rfps

has_many :rfps, :through => :payment_rfps

class paymentrfp < activerecord::base

attr_accessible :payment_gateway_id,:rfp_id

belongs_to :payment_gateway

belongs_to :rfp end

rfp.rb

has_many :payment_rfps

has_many :payment_gateways, :through => :payment_rfps

my view part

    <div class = "lft_cms" ><b>payment gateways</b>      <div class="field">      <%= hidden_field_tag "rfp[ payment_gateway_ids][]", nil %>        <% paymentgateway.all.each |payment_gateway| %>          <%= check_box_tag "rfp[payment_gateway_ids][]",payment_gateway.id, @rfp.payment_gateway_ids.include?(payment_gateway.id), :id => dom_id(payment_gateway) %>           <%= label_tag dom_id(payment_gateway), payment_gateway.name %><br> <% end %>     </div> 

how can add text field give additional option fill appreciated.thanks

first of all, paymentgateway.all bad idea. shouldn't there in view loaded controller in instance variable. please change that.

one way define attribute, let 'additional_info':

<% paymentgateway.all.each |pg| %>   <%= check_box_tag ..., onclick: "$('#{pg}_info').show(); $('#{pg}_info').siblings().hide();" %>   ... <% end %>  <div class="additional_infos">   <%= f.input :gateway1_info, label: "gateway" ... %> </div> 

Comments

Popular posts from this blog

windows - Single EXE to Install Python Standalone Executable for Easy Distribution -

c# - Access objects in UserControl from MainWindow in WPF -

javascript - How to name a jQuery function to make a browser's back button work? -