Module: Card::Set::All::FormElements::HtmlFormat
- Extended by:
- Card::Set::AbstractFormat
- Defined in:
- platypus/tmp/set/gem-defaults/mod011-edit/all/form_elements.rb
Constant Summary collapse
- FIELD_HELPERS =
%w[ hidden_field color_field date_field datetime_field datetime_local_field email_field month_field number_field password_field phone_field range_field search_field telephone_field text_area text_field time_field url_field week_field file_field label check_box radio_button ].freeze
Instance Method Summary collapse
-
#cancel_button(args = {}) ⇒ Object
redirect to *previous if no :href is given.
-
#cancel_strategy(redirect, href) ⇒ Object
-
#hidden_tags(hash, base = nil, options = {}) ⇒ Object
convert hash into a collection of hidden tags.
-
#path_to_previous ⇒ Object
-
#process_hidden_value(val, base, options = {}) ⇒ Object
-
#submit_button(args = {}) ⇒ String
Generates an HTML submit button with optional parameters.
-
#success_tags(opts) ⇒ Object
Instance Method Details
#cancel_button(args = {}) ⇒ Object
redirect to *previous if no :href is given
74 75 76 77 78 79 80 81 82 83 |
# File 'platypus/tmp/set/gem-defaults/mod011-edit/all/form_elements.rb', line 74 def args={} return unless voo.show? :cancel_button text = args.delete(:text) || "Cancel" add_class args, "btn btn-#{args.delete(:situation) || 'secondary'}" add_class args, cancel_strategy(args[:redirect], args[:href]) args[:href] ||= path_to_previous args["data-remote"] = true link_to text, args end |
#cancel_strategy(redirect, href) ⇒ Object
85 86 87 88 |
# File 'platypus/tmp/set/gem-defaults/mod011-edit/all/form_elements.rb', line 85 def cancel_strategy redirect, href redirect = href.blank? if redirect.nil? redirect ? "redirecter" : "slotter" end |
#hidden_tags(hash, base = nil, options = {}) ⇒ Object
convert hash into a collection of hidden tags
16 17 18 19 20 21 22 |
# File 'platypus/tmp/set/gem-defaults/mod011-edit/all/form_elements.rb', line 16 def hash, base=nil, ={} hash ||= {} hash.inject("") do |result, (key, val)| new_base = base ? "#{base}[#{key}]" : key result + process_hidden_value(val, new_base, ) end end |
#path_to_previous ⇒ Object
90 91 92 |
# File 'platypus/tmp/set/gem-defaults/mod011-edit/all/form_elements.rb', line 90 def path_to_previous path mark: "*previous" end |
#process_hidden_value(val, base, options = {}) ⇒ Object
24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'platypus/tmp/set/gem-defaults/mod011-edit/all/form_elements.rb', line 24 def process_hidden_value val, base, ={} case val when Hash val, base, when Array base += "[]" val.map do |v| hidden_field_tag base, v, end.join else hidden_field_tag base, val, end end |
#submit_button(args = {}) ⇒ String
Generates an HTML submit button with optional parameters.
66 67 68 69 70 71 |
# File 'platypus/tmp/set/gem-defaults/mod011-edit/all/form_elements.rb', line 66 def args={} text = args.delete(:text) || "Submit" args.reverse_merge! situation: "primary", data: {} args[:data][:disable_with] ||= args.delete(:disable_with) || "Submitting" text, args end |
#success_tags(opts) ⇒ Object
9 10 11 12 13 |
# File 'platypus/tmp/set/gem-defaults/mod011-edit/all/form_elements.rb', line 9 def opts return "" unless opts.present? success: opts end |