class Aerogel::Forms::FormBuilder
Constants
- DEFAULT_OPTIONS
Attributes
content[RW]
options[RW]
Public Class Methods
new( object, options, &block )
click to toggle source
Calls superclass method
# File lib/aerogel/forms/form_builder.rb, line 16 def initialize( object, options, &block ) super( object, nil, nil, options, &block ) @hiddens = [] @options = DEFAULT_OPTIONS.dup.deep_merge( options ) @options[:cancel_url] ||= back hidden csrf_field_name, csrf_token if csrf_protected? hidden :id, object.id if object.respond_to? :id end
Public Instance Methods
html_params()
click to toggle source
Returns a Hash with <form ..> tag attributes.
# File lib/aerogel/forms/form_builder.rb, line 57 def html_params attrs = @options[:html_params].dup attrs.merge!({ :method => @options[:method], # :action => @options[:action] }) attrs[:action] = @options[:action] if @options[:action] attrs[:enctype] = 'multipart/form-data' if @options[:multipart] attrs.map{|n, v| v.nil? ? "#{n}" : "#{n}=\"#{v}\""}.join(" ") end
wrap( content )
click to toggle source
# File lib/aerogel/forms/form_builder.rb, line 48 def wrap( content ) erb :"form_builder/#{@style}/form", locals: { form: self, content: content }, layout: false # self.instance_exec( self, &STYLES[@style][:form_decorator] ) end