开发者

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!


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

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


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"


You have to pass first parameter as name, and second as value. Also, you can override the name of the parameters like this.

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

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜