Class: Espresso::View::FormBuilder
- Inherits:
-
Formtastic::SemanticFormBuilder
- Object
- Formtastic::SemanticFormBuilder
- Espresso::View::FormBuilder
- Defined in:
- lib/espresso/view/form_builder.rb
Instance Method Summary collapse
- #commit_button(*args) ⇒ Object
-
#inline_errors_for(method, options = nil) ⇒ Object
:nodoc:.
- #submit(value = nil, options = {}) ⇒ Object
- #submit_default_value ⇒ Object
Instance Method Details
#commit_button(*args) ⇒ Object
39 40 41 42 43 44 45 46 47 48 |
# File 'lib/espresso/view/form_builder.rb', line 39 def (*args) = args. = .delete(:button_html) || {} .merge!(:class => [[:class], form_action].compact.join(' ')) element_class = ['commit', .delete(:class)].compact.join(' ') accesskey = (.delete(:accesskey) || @@default_commit_button_accesskey) unless .has_key?(:accesskey) = .merge(:accesskey => accesskey) if accesskey template.content_tag(:li, self.submit(.delete(:label), ), :class => element_class) end |
#inline_errors_for(method, options = nil) ⇒ Object
:nodoc:
14 15 16 17 18 19 20 21 22 |
# File 'lib/espresso/view/form_builder.rb', line 14 def inline_errors_for(method, = nil) #:nodoc: if render_inline_errors? errors = Array(@object.errors[method.to_sym]) + Array(@object.errors[:"#{method}_id"]) send(:"error_#{@@inline_errors}", [*errors]) if errors.present? else nil end end |
#submit(value = nil, options = {}) ⇒ Object
8 9 10 11 12 |
# File 'lib/espresso/view/form_builder.rb', line 8 def submit(value=nil, ={}) value, = nil, value if value.is_a?(Hash) value ||= submit_default_value @template.submit_tag(value, .reverse_merge(:id => "#{object_name}_submit")) end |
#submit_default_value ⇒ Object
24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/espresso/view/form_builder.rb', line 24 def submit_default_value model = if object.class.respond_to?(:model_name) object.class.human_name else @object_name.to_s.humanize end defaults = [] defaults << :"helpers.submit.#{object_name}.#{form_action}" defaults << :"helpers.submit.#{form_action}" defaults << "#{form_action.to_s.humanize} #{model}" I18n.t(defaults.shift, :model => model, :default => defaults) end |