Module: BootstrapForms::Helpers::FormTagHelper
- Includes:
- Wrappers
- Defined in:
- lib/bootstrap_forms/helpers/form_tag_helper.rb
Instance Method Summary collapse
- #bootstrap_actions(&block) ⇒ Object
- #bootstrap_button_tag(*args) ⇒ Object
- #bootstrap_cancel_tag(*args) ⇒ Object
- #bootstrap_submit_tag(*args) ⇒ Object
- #uneditable_input_tag(name, *args) ⇒ Object
Instance Method Details
#bootstrap_actions(&block) ⇒ Object
71 72 73 74 75 76 77 78 79 80 81 |
# File 'lib/bootstrap_forms/helpers/form_tag_helper.rb', line 71 def bootstrap_actions(&block) # This somethat redundant arrangement is necessary (according to the test cases) to make this call work with Slim, ERB, and HAML. # Though oddly enough this Slim block test still fails yet works in production. Not sure why this is but, nevertheless # we keep this in place. if block_given? content_tag(:div, :class => 'form-actions', &block) else content = [bootstrap_submit_tag, bootstrap_cancel_tag].join(' ').html_safe content_tag(:div, content, :class => 'form-actions') end end |
#bootstrap_button_tag(*args) ⇒ Object
45 46 47 48 49 50 51 52 |
# File 'lib/bootstrap_forms/helpers/form_tag_helper.rb', line 45 def (*args) = args. [:class] ||= 'btn btn-primary' name = args.shift || 'Submit' # button_tag() renders <input type="button"> content_tag(:button, name, ).html_safe end |
#bootstrap_cancel_tag(*args) ⇒ Object
62 63 64 65 66 67 68 69 |
# File 'lib/bootstrap_forms/helpers/form_tag_helper.rb', line 62 def bootstrap_cancel_tag(*args) = args. [:class] ||= 'btn cancel' [:back] ||= 'javascript:history.go(-1)' name = args.shift || 'Cancel' link_to(name, [:back], .except(:back)).html_safe end |
#bootstrap_submit_tag(*args) ⇒ Object
54 55 56 57 58 59 60 |
# File 'lib/bootstrap_forms/helpers/form_tag_helper.rb', line 54 def bootstrap_submit_tag(*args) = args. [:class] ||= 'btn btn-primary' name = args.shift || 'Submit' submit_tag(name, ).html_safe end |
#uneditable_input_tag(name, *args) ⇒ Object
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/bootstrap_forms/helpers/form_tag_helper.rb', line 24 def uneditable_input_tag(name, *args) @name = name @field_options = args. @args = args # Padrino will always generate a label's for attribute, this results in invalid HTML. # label_field will use :id as the for attribute if present. @field_options[:id] = nil unless @field_options[:id] control_group_div do label_field << input_div do # Due to how Padrino implements ERB this block (and others) will be called many (4?) times. # To avoid string accumulation under :class -and to keep option passing somewhat straightforward- we just dup() = @field_options.dup [:class] = [[:class], 'uneditable-input'].compact.join " " content_tag(:span, escape_html([:value]), (.except(:value))) end end.html_safe end |