I've been digging the new form block methods form_for and form_remote_for. I submitted a patch #3268 [1] that adds label helpers to the mix:
<%= label_tag 'post_title', 'Title' %> <%= label_for 'post', 'title' %> <% fields_for :post, @post do |f| -%> <%= f.label_for :title %> <% end -%> This sets the for="" attribute to point to the input tag automatically. Ulysses suggested I take it a step further, and allow you to subclass FormBuilder for your own purposes. I made a simple LabeledFormBuilder that formats your fields like so: <p><label for=""><br /><input ... /></p> using: <% labeled_form_for :foo, @foo do |f| %> <%= f.text_field :bar %> <% end -%> Having thought about it some more after submitting the final diff, I think this labeled_form_for stuff should be extracted to a plugin to show how to write your own FormBuilders. Who knows, it could be the start of an admin scaffolding plugin? Thoughts? 1. http://dev.rubyonrails.org/ticket/3268 -- rick http://techno-weenie.net _______________________________________________ Rails-core mailing list [email protected] http://lists.rubyonrails.org/mailman/listinfo/rails-core
