Module: JqueryUiForm::Helpers::ButtonHelper
- Included in:
- FormBuilder
- Defined in:
- lib/jquery_ui_form/helpers/button_helper.rb
Instance Method Summary collapse
- #button(name, options = {}) ⇒ Object
- #cancel(name = nil, options = {}) ⇒ Object
- #submit(name = nil, options = {}) ⇒ Object
Instance Method Details
#button(name, options = {}) ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
# File 'lib/jquery_ui_form/helpers/button_helper.rb', line 5 def (name, = {}) if use_i18n && !.delete(:translate) name = I18n.t(name) elsif name == name.to_sym name = name.to_s.upcase.humanize end ([:class] ||= "") << " ui-button" [:type] ||= "submit" if (icon = .delete(:icon)) ["data-icon"] = "ui-icon-#{icon}" end template.(name, ) end |
#cancel(name = nil, options = {}) ⇒ Object
28 29 30 31 32 33 34 35 |
# File 'lib/jquery_ui_form/helpers/button_helper.rb', line 28 def cancel(name=nil, = {}) .merge!(name) && name = nil if name.is_a?(Hash) [:type] ||= "reset" [:icon] ||= "close" ([:class] ||= "") << " ui-state-error" name ||= :cancel (name, ) end |
#submit(name = nil, options = {}) ⇒ Object
20 21 22 23 24 25 26 |
# File 'lib/jquery_ui_form/helpers/button_helper.rb', line 20 def submit(name=nil, = {}) .merge!(name) && name = nil if name.is_a?(Hash) [:type] ||= "submit" [:icon] ||= "check" name ||= (@object && @object.respond_to?(:new_record?) && @object.new_record? ? :create : :update ) (name, ) end |