module BootstrapForms::Helpers::FormTagHelper
Public Instance Methods
bootstrap_actions(&block)
click to toggle source
# 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_cancel_tag(*args)
click to toggle source
# File lib/bootstrap_forms/helpers/form_tag_helper.rb, line 62 def bootstrap_cancel_tag(*args) options = args.extract_options! options[:class] ||= 'btn cancel' options[:back] ||= 'javascript:history.go(-1)' name = args.shift || 'Cancel' link_to(name, options[:back], options.except(:back)).html_safe end
bootstrap_submit_tag(*args)
click to toggle source
# File lib/bootstrap_forms/helpers/form_tag_helper.rb, line 54 def bootstrap_submit_tag(*args) options = args.extract_options! options[:class] ||= 'btn btn-primary' name = args.shift || 'Submit' submit_tag(name, options).html_safe end
uneditable_input_tag(name, *args)
click to toggle source
# File lib/bootstrap_forms/helpers/form_tag_helper.rb, line 24 def uneditable_input_tag(name, *args) @name = name @field_options = args.extract_options! @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() options = @field_options.dup options[:class] = [options[:class], 'uneditable-input'].compact.join " " content_tag(:span, escape_html(options[:value]), objectify_options(options.except(:value))) end end.html_safe end