хамбо формбилдер - PullRequest
       2

хамбо формбилдер

0 голосов
/ 23 августа 2010

Я конвертирую старую программу в haml, и у меня возникла проблема с моим пользовательским formbuilder. Проблема заключается в простом добавлении перевода строки между меткой поля и тегом ввода.

Вот оригинальный FormBuilder:

# Custom FormBuilder
class SuperFormBuilder < ActionView::Helpers::FormBuilder

  # Create an array of helpers to override with our label builder
  helpers = field_helpers +
            %w{calendar_date_select date_select datetime_select time_select} +
            %w{collection_select select country_select time_zone_select} -
            %w{hidden_field label fields_for} # Don't decorate these

  helpers.each do |name|

    define_method(name) do |field, *args|

      # Get the hash option (EG the field involved)
      options = args.extract_options!

      # Create a label for that field
      label = label(field, options[:label], :class => options[:label_class])

      # Create an inline error
      error = error_message_on(field)

      # Wrap label in paragraph, include the original helper EG: text-field
      @template.content_tag(:p, label + "<br />" + super + error)  #wrap with a paragraph
    end
  end

  # Override the submit button
  def submit
    # Calculate custom text for submit button.
    prefix = object.new_record? ? "Create" : "Update"

    # Wrap submit button in paragraph tags and add custom text.
    @template.content_tag(:p,super(prefix, :id => "apply" ))
  end
end

Если я использую% br, где это
, это вообще не работает. Есть ли способ изменить это, чтобы хорошо хамло?

1 Ответ

0 голосов
/ 23 августа 2010

Что произойдет, если вы просто используете tag("br")?

...