This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class BootstrapFormBuilder < ActionView::Helpers::FormBuilder | |
delegate :capture, :content_tag, :tag, to: :@template | |
%w[text_field text_area password_field collection_select email_field].each do |method_name| | |
define_method(method_name) do |name, *args| | |
errors = object.errors[name].any?? " error" : "" | |
error_msg = object.errors[name].any?? content_tag(:span, object.errors[name].join(","), class: "help-inline") : "" | |
content_tag :div, class: "control-group#{errors}" do |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def select_from_chosen(item_text, options) | |
field_id = find_field(options[:from])[:id] | |
within "##{field_id}_chzn" do | |
find('a.chzn-single').click | |
input = find("div.chzn-search input") | |
item_text.each_char do |char| | |
input.base.invoke('keypress', false, false, false, false, char.ord, nil); | |
end | |
find('ul.chzn-results').click | |
input.base.invoke('keypress', false, false, false, false, 40, nil); # down arrow |