I want to pass a parameter to my controller, its a simple check box but I dont know how I introduce this in my form_for
of a model, see this is my view:
<%= form_for @finance,:html => { :id => 'go_finance' } do |f| %>
<br>
Transferir de :<%= f.select :from_money, @places.map { |p| [p.place, p.id] } %>
para: <%= f.select :to_money, @places.map { |p| [p.place, p.id] } %>
<br>
Entrada: <%= f.text_field :input,:id => "input",:placeholder => "Quanto foi ganho ?" %>
Saída: <%= f.text_field :output,:id => "output",:placeholder => "Quanto foi gasto ?" %>
<br>
Nota: <%= f.text_area :note %>
<%= f.submit %>
<% end -%>
I want to make a extra checkbox but how can I make this, no a object in model but a object some to check to make a if else in controller, if check if no check, please help-me and thanks a lot, thanks
You can try to use check_box_tag
<%= check_box_tag :my_attr %>
then just check for a params[:my_attr]
in the controller. If params[:my_attr]
exists in the controller, then the checkbox is checked.
Add random checkboxes with check_box_tag
:
<%= label_tag :rnd_boolean %>
<%= check_box_tag :rnd_boolean %>
# then in your controller
if params[:rnd_boolean]
do_suff
else
do_other_stuff
end
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With