Method: Formtastic::Helpers::ButtonsHelper#commit_button
- Defined in:
- lib/formtastic/helpers/buttons_helper.rb
#commit_button(*args) ⇒ Object
f.commit_button is deprecated in favor of f.actions and will be removed after 2.1
document i18n keys
strange that :accesskey seems to be supported in the top level args as well as :button_html
Creates a submit input tag with the value "Save [model name]" (for existing records) or
"Create [model name]" (for new records) by default. The output is an <input> tag with the
type of submit and a class of either create or update (if Formtastic can determin if)
the record is new or not) with submit as a fallback class. The submit button is wrapped in
an <li> tag with a class of commit, and is intended to be rendered inside a #buttons
block which wraps the button in a fieldset and ol.
The textual value of the label can be changed from this default through the :label
argument or through i18n.
You can pass HTML attributes down to the <input> tag with the :button_html option, and
pass HTML attributes to the wrapping <li> tag with the :wrapper_html option.
247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 |
# File 'lib/formtastic/helpers/buttons_helper.rb', line 247 def (*args) ::ActiveSupport::Deprecation.warn("f.commit_button is deprecated in favour of f.action(:submit) and will be removed from Formtastic after 2.1. Please see ActionsHelper and InputAction or ButtonAction for more information") = args. text = .delete(:label) || args.shift text = (localized_string(, text, :action, :model => ) || Formtastic::I18n.t(, :model => )) unless text.is_a?(::String) = .delete(:button_html) || {} [:id] ||= "#{@object_name}_submit" .merge!(:class => [[:class], ].compact.join(' ')) wrapper_html = .delete(:wrapper_html) || {} wrapper_html[:class] = ( << wrapper_html[:class]).flatten.compact.join(' ') accesskey = (.delete(:accesskey) || ) unless .has_key?(:accesskey) = .merge(:accesskey => accesskey) if accesskey template.content_tag(:li, Formtastic::Util.html_safe(submit(text, )), wrapper_html) end |