I have a form_for where I have some field related to form object and there are some fields which are not related to form object so for those field I am using text_field_tag. But those field are like key - value pair, so when submitting a form, I want to combine or rather send in hash format so that in controller code I can easily save these values together.
Here is my form_for code
[Demo]
<%= form_for [@var], :url => {:action => form_action}, :html => {:id => form_id} do |f| %>
<table border=0 cellpadding="0" cellspacing="8" id='psp-config-form' >
<tr class='psp_config_row'>
<td><label for=''>Screen Label</label></td>
<td>
<%= text_field_tag "screen_label[]", "", :size => 20, :class => 'search-txt-input', :maxlength => 360 %>
</td>
<td><label for=''>Value</label></td>
<td>
<%= text_field_tag "screen_value[]", "", :size => 20, :class => 'search-txt-input', :maxlength => 360 %>
</td>
<td><label for=''>Mask Value</label></td>
<td>
<%= check_box_tag "is_masked[]", "", false, :class => 'search-txt-input' %>
</td>
<td>
<%= link_to 'Delete', "javascript:void(0);", :class => 'linkclass delete_link', :title => 'Confirmation', :style=>"display: none" %>
</td>
</tr>
<tr>
<td></td>
<td class="add_psp_config_button">
<%= link_to "Add Additional PSP credentials", "javascript:void(0);", :title => "Add PSP Config Values", :class => "actionBtn button", :id => "add_psp_config_button" %>
<td>
</tr>
<tr>
<td></td>
<td>
<%= f.submit 'Add PSP',:class => 'loginBtn', :id => 'add-psp-button'%>
</td>
<td>
<%= text_field_tag 'cancel', 'Cancel', :type=> 'button', :class => 'loginBtn' %>
</td>
</tr>
Here is the current params sent to controller:
Parameters: {"utf8"=>"?", "authenticity_token"=>"sMZYtNbYGXf3iDtYrOVafHxwzFTM4U8+V5xOyFgr5/8=", "psp_admin_portal"=>{"psp_name"=>"google", "psp_url"=>"https://google.com", "psp_username"=>"google-username", "psp_password=>"XXXX"}, "screen_label"=>["label1", "label2", "label3"], "screen_value"=>["val1", "val2", "val3"], "commit"=>"Add PSP"}
So here I am finding a way using which I can send screen_lable and value params like this:
{screen_params => {"label1" => "val1", "label2" => "val2"}, ...}
let me know if any of you have any idea on this.
Thanks, Dean