# frozen_string_literal: true
module Formtastic
module Actions
# Outputs an `` or `` wrapped in the standard `
`
# wrapper. This the default for `:submit` and `:reset` actions, but `:as => :button` is also
# available as an alternative.
#
# @example The `:as` can be ommitted, these are functionally equivalent
# <%= f.action :submit, :as => :input %>
# <%= f.action :submit %>
#
# @example Full form context and output
#
# <%= semantic_form_for(@post) do |f| %>
# <%= f.actions do %>
# <%= f.action :reset, :as => :input %>
# <%= f.action :submit, :as => :input %>
# <% end %>
# <% end %>
#
#
#
#
#
# @example Specifying a label with a String
# <%= f.action :submit, :as => :input, :label => "Go" %>
#
# @example Pass HTML attributes down to the ``
# <%= f.action :submit, :as => :input, :button_html => { :class => 'pretty', :accesskey => 'g', :disable_with => "Wait..." } %>
#
# @example Access key can also be set as a top-level option
# <%= f.action :submit, :as => :input, :accesskey => 'g' %>
#
# @example Pass HTML attributes down to the `
` wrapper (classes are appended to the existing classes)
# <%= f.action :submit, :as => :input, :wrapper_html => { :class => 'special', :id => 'whatever' } %>
# <%= f.action :submit, :as => :input, :wrapper_html => { :class => ['extra', 'special'], :id => 'whatever' } %>
# @todo document i18n keys
# @todo document i18n translation with :label (?)
class InputAction
include Base
include Buttonish
# @see Formtastic::Helpers::ActionHelper#action
# @option *args :label [String, Symbol]
# Override the label text with a String or a symbol for an i18n translation key
#
# @option *args :button_html [Hash]
# Override or add to the HTML attributes to be passed down to the `` tag
#
# @option *args :wrapper_html [Hash]
# Override or add to the HTML attributes to be passed down to the wrapping `
` tag
#
def to_html
wrapper do
builder.submit(text, button_html)
end
end
end
end
end