class Aerogel::Forms::FormButton
Button represents a button in a form object.
Constants
- KNOWN_OPTIONS
Known options to a field are processed, the rest (unknown options) goes as html params.
Attributes
form_object[RW]
label[RW]
options[RW]
type[RW]
Public Class Methods
new( form_object, type, options = {} )
click to toggle source
# File lib/aerogel/forms/form_button.rb, line 13 def initialize( form_object, type, options = {} ) default_opts = {} default_opts[:label] = I18n.t "aerogel.forms.buttons.#{type}", default: type.to_s.humanize if String === type || type == :save || type == :create type = :submit elsif type == :cancel default_opts[:url] = form_object.options[:cancel_url] end options = default_opts.deep_merge options self.form_object = form_object self.type = type self.options = options end
Public Instance Methods
html_params()
click to toggle source
Returns a string of html params for the <button …> tag.
# File lib/aerogel/forms/form_button.rb, line 34 def html_params attrs = @options.except( *KNOWN_OPTIONS ) attrs = attrs.deep_merge( @options[:html_params] ) if @options.key? :html_params attrs.to_html_params end