My Hidden Field:
- @calc.results.each do |k, v|
= hidden_field :calc_result, :value => "#{k[:total_interest]}"
Which returns :
"calc_result"=>
{"value214.14"=>"",
...
How can I write the hidden_field so that it produces :
"value" => "214.14"
You don't need to pass :value, just say this:
= hidden_field_tag :calc_result, "#{k[:total_interest]}"
That should get you what you want.
By using hidden_field
, the name attribute is interpreted from the field name (in this case :calc_result
.
If value
is not a field in the model, you could use hidden_field_tag
instead.
= hidden_field_tag "value", k[:total_interest]}
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.