On 7/4/06, Erik Kastner <[EMAIL PROTECTED]> wrote:
>From rails/actionpack/test/template/form_helper_test.rb
http://dev.rubyonrails.org/browser/trunk/actionpack/test/template/form_helper_test.rb
starting at line 345

  class LabelledFormBuilder < ActionView::Helpers::FormBuilder
    (field_helpers - %w(hidden_field)).each do |selector|
      src = <<-END_SRC
        def #{selector}(field, *args, &proc)
          "<label for='\#{field}'>\#{field.to_s.humanize}:</label> " +
super + "<br/>"
        end
      END_SRC
      class_eval src, __FILE__, __LINE__
    end
  end


Thanks for the link.

I think this is a good idea but is not so flexible. If I am reading
this correctly, this will produce

<label for="foo">Foo</label><input type="submit" name="foo /><br/>

This is nice for the very simplest cases and I'd like to see that in
the core but what about when I want to do just a little more.

Perhaps I want to specify non-automatic label content for just one field.

Perhaps I want more HTML control so the CSS will be easier. I don't
ever really use <br />. (Side note: I think they should add a space
between the 'r' and the '/' for safety') Another HTML issue is all
form inputs will not be <input> tags. First the text area is not. This
makes the CSS more difficult which is why I wrap all my inputs in
<span class="input"> or even better just <dd> as the whole form is
part of a <dl>.

I think this

<%= f.label :name %>

would be a nice addition to the core also. I've been wanting this for
a long time. The label can also be nicely wrapped in <span
class="labelWithError"> and hiding this can be set individually like
the input elements.

The only reason I don't submit a patch is I don't know if I've got it
right and I don't know if the higher-ups would be receptive.

Peter
_______________________________________________
Rails-core mailing list
Rails-core@lists.rubyonrails.org
http://lists.rubyonrails.org/mailman/listinfo/rails-core

Reply via email to