module JqueryUiForm module Helpers module ButtonHelper def button(name, options = {}) if use_i18n && !options.delete(:translate) name = I18n.t(name) elsif name == name.to_sym name = name.to_s.upcase.humanize end (options[:class] ||= "") << " ui-button" options[:type] ||= "submit" if (icon = options.delete(:icon)) options["data-icon"] = "ui-icon-#{icon}" end template.button_tag(name, options) end def submit(name=nil, options = {}) options.merge!(name) && name = nil if name.is_a?(Hash) options[:type] ||= "submit" options[:icon] ||= "check" name ||= (@object && @object.respond_to?(:new_record?) && @object.new_record? ? :create : :update ) button(name, options) end def cancel(name=nil, options = {}) options.merge!(name) && name = nil if name.is_a?(Hash) options[:type] ||= "reset" options[:icon] ||= "close" (options[:class] ||= "") << " ui-state-error" name ||= :cancel button(name, options) end end end end