mjbellantoni / formtastic-bootstrap

Formtastic form builder to generate Twitter Bootstrap-friendly markup.
MIT License
443 stars 218 forks source link

semantic_fields_for generates old style markup #76

Closed meliborn closed 9 years ago

meliborn commented 11 years ago

All parent inputs has twitter bootstrap markup, but semantic_fields_for inputs has old style markup with <li> and <ol>

sodabrew commented 11 years ago

(I added backticks around your HTML elements to force them to appear in the issue description).

Please do investigate and suggest any changes to formtastic-bootstrap you need to resolve this issue.

meliborn commented 11 years ago

I don't know why semantic_fields_for generate old style markup, when semantic_form_for generate normal bootstrap style. Maybe problem with form builder...Only I have this kind of problem or gem doesn't support it?

meliborn commented 11 years ago

I discovered that problem only with custom inputs. For example:

class SurveyorCheckBoxesInput < Formtastic::Inputs::CheckBoxesInput
  include Surveyor::Helpers::FormtasticCustomInput
  def to_html
    super
  end
  def choice_html(choice)
    output = "" 
    output << template.content_tag(:label,
      hidden_fields? ?
        check_box_with_hidden_input(choice) :
        check_box_without_hidden_input(choice) <<
      choice_label(choice),
      label_html_options.merge(:for => choice_input_dom_id(choice), :class => nil)
    )
    output << builder.text_field(:response_other, input_html_options_with(choice, :response_other)) if options[:response_class] == "other_and_string"
    output << builder.text_field(response_class_to_method(options[:response_class]), input_html_options_with(choice, options[:response_class])) if %w(date datetime time float integer string other_and_string).include? options[:response_class]
    output << builder.text_area(:text_value, input_html_options_with(choice, :text_value)) if options[:response_class] == "text"
    output.html_safe
  end
  def checked?(value)
    selected_values.include?(value.to_s)
  end
  def disabled?(value)
    disabled_values.include?(value) || input_html_options[:disabled] == true
  end
  def make_selected_values
    if object.respond_to?(method)
      selected_items = [object.send(method)].compact.flatten.map(&:to_s)

      [*selected_items.map { |o| send_or_call_or_object(value_method, o) }].compact
    else
      []
    end
  end
end
sodabrew commented 11 years ago

What is include Surveyor::Helpers::FormtasticCustomInput ?

jtomaszewski commented 9 years ago

Please include all the source (f.e. of the Surveyor::Helpers::FormtasticCustomInput) so we can investigate. Then we'll reopen the issue.

P.S. In my opinion, there should be no problem with custom inputs inherited from formtastic-bootstrap inputs, as I have a couple of them in my own rails app.