开发者

Rails how to programatically get html id from form

Say I have a Rails form like the following

 <%开发者_JAVA技巧 form_for @model do |f| %>
   <%= f.label :column %>
   <%= f.check_box :column %>
 <% end %>

Is there a way I can get the html id that will be generated for the 'column' check box? What would be great is if there was a way to add in

  <%= f.observe_field :column, options %>

Anyone know how to add this to FormBuilder?


For generating an element's id programatically, see this. As it seems, there is no easy way out.

You could add this to FormBuilder by wrapping up certain field tags. See for example this.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜