Module: BootstrapFormHelper
- Includes:
- ActionView::Helpers, PanelHelper
- Included in:
- ActionView::Helpers::FormBuilder
- Defined in:
- app/helpers/bootstrap_form_helper.rb
Constant Summary collapse
- FIELD_HELPERS =
[:email_field, :password_field, :text_field, :text_area, :search_field, :telephone_field, :url_field, :number_field, :file_field, :date_field, :time_field, :month_field, :week_field, :datetime_field, :datetime_local_field]
Instance Method Summary collapse
- #fields_for(record_name, record_object = nil, options = {}, &block) ⇒ Object
- #form_for(record, options = {}, &block) ⇒ Object
- #render_field(inline_style, label_proc, input_proc) ⇒ Object
- #render_help_text(help) ⇒ Object
- #render_input_addon(content) ⇒ Object
Methods included from PanelHelper
Instance Method Details
#fields_for(record_name, record_object = nil, options = {}, &block) ⇒ Object
56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 |
# File 'app/helpers/bootstrap_form_helper.rb', line 56 def fields_for(record_name, record_object = nil, = {}, &block) fieldset = HashWithIndifferentAccess.new(.delete(:fieldset)) if fieldset.present? type = get_panel_type(fieldset[:type]) title = fieldset[:title] end content_tag :fieldset, class: "panel #{type}" do ((title.present? ? (content_tag :div, title, class: 'panel-heading') : '') + (content_tag :div, class: 'panel-body' do super end)).html_safe end end |
#form_for(record, options = {}, &block) ⇒ Object
13 14 15 16 17 18 19 20 |
# File 'app/helpers/bootstrap_form_helper.rb', line 13 def form_for(record, = {}, &block) = [:html] ||= {} prepend_class(, get_form_layout(.delete(:layout))) [:html] = super end |
#render_field(inline_style, label_proc, input_proc) ⇒ Object
88 89 90 91 92 93 94 95 96 |
# File 'app/helpers/bootstrap_form_helper.rb', line 88 def render_field(inline_style, label_proc, input_proc) content_tag :div, class: 'form-group' do if inline_style (label_proc.call + (content_tag :div, class: 'col-sm-9', &input_proc)).html_safe else (label_proc.call + input_proc.call).html_safe end end end |
#render_help_text(help) ⇒ Object
72 73 74 |
# File 'app/helpers/bootstrap_form_helper.rb', line 72 def render_help_text(help) (help.present? ? "<span class='help-block text-left'>#{help}</span>" : '').html_safe end |
#render_input_addon(content) ⇒ Object
76 77 78 79 80 81 82 83 84 85 86 |
# File 'app/helpers/bootstrap_form_helper.rb', line 76 def render_input_addon(content) return ('').html_safe if content.blank? if content.is_a?(String) "<span class='input-group-addon'>#{content}</span>".html_safe elsif content.is_a?(Hash) && content.key?(:icon) "<span class='input-group-addon'>#{icon(content[:icon])}</span>".html_safe else ('').html_safe end end |