Module: Formtastic::Helpers::ActionHelper
- Included in:
- FormBuilder
- Defined in:
- lib/formtastic/helpers/action_helper.rb
Instance Method Summary collapse
-
#action(method, options = {}) ⇒ Object
Renders an action for the form (such as a subit/reset button, or a cancel link).
Instance Method Details
#action(method, options = {}) ⇒ Object
document i18n keys
Renders an action for the form (such as a subit/reset button, or a cancel link).
Each action is wrapped in an <li class="action">
tag with other classes added based on the
type of action being rendered, 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 the default through the :label
argument or through i18n.
If using i18n, you'll need to provide the following translations:
en: formtastic: actions: create: "Create new %model" update: "Save %model" cancel: "Cancel" reset: "Reset form" submit: "Submit"
For forms with an object present, the update
key will be used if calling persisted?
on
the object returns true (saving changes to a record), otherwise the create
key will be
used. The submit
key is used as a fallback when there is no object or we cannot determine
if create
or update
is appropriate.
79 80 81 82 83 84 85 86 |
# File 'lib/formtastic/helpers/action_helper.rb', line 79 def action(method, = {}) = .dup # Allow options to be shared without being tainted by Formtastic [:as] ||= default_action_type(method, ) klass = namespaced_action_class([:as]) klass.new(self, template, @object, @object_name, method, ).to_html end |