Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Rails : How to assign name and id to hidden_field_tag?

How to assign specific id and name to hidden_field_tag ?

Like this,

hidden_field_tag(:id => "page_no",:name => "page", :value => "1" )

Any Idea!

like image 321
krunal shah Avatar asked Mar 14 '11 06:03

krunal shah


2 Answers

hidden_field_tag("page_name", "1", :id => "page_no")

per http://api.rubyonrails.org/classes/ActionView/Helpers/FormTagHelper.html#method-i-hidden_field_tag

like image 149
Mike Lewis Avatar answered Oct 05 '22 10:10

Mike Lewis


It takes hidden_field_tag(name, value = nil, options = {})

So the third parameter is for options.

hidden_field_tag("page", "1", {:id => "page_no"}) would set name to "page", value to "1" and id to "page_no"

like image 24
lebreeze Avatar answered Oct 05 '22 10:10

lebreeze