Rails: how to assign name and id to hidden_field_tag?

How to assign a specific id and name to hidden_field_tag?

Like this,

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

Any idea!

+4
source share
3 answers
+16
source

Requires hidden_field_tag(name, value = nil, options = {})

So, the third parameter for the parameters.

hidden_field_tag("page", "1", {:id => "page_no"}) specifies the name "page", the value "1" and the identifier "page_no"

+6
source

You must pass the first parameter as a name and the second as a value. In addition, you can override the name of parameters such as this.

  <%=hidden_field_tag :param_name, 'param_value', {:id => 'ashish_id', :name => 'another_name'}%> 
+2
source

Source: https://habr.com/ru/post/1343588/


All Articles