Clean up style around form_for and friends a bit
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@3573 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
This commit is contained in:
parent
344ae8326a
commit
a04a849d15
@ -121,9 +121,10 @@ module FormHelper
|
|||||||
# end
|
# end
|
||||||
#
|
#
|
||||||
def form_for(object_name, object, options = {}, &proc)
|
def form_for(object_name, object, options = {}, &proc)
|
||||||
concat form_tag(options, options.delete(:html) || {}), proc.binding
|
raise ArgumentError, "Missing block" unless block_given?
|
||||||
|
concat(form_tag(options, options.delete(:html) || {}), proc.binding)
|
||||||
fields_for(object_name, object, options, &proc)
|
fields_for(object_name, object, options, &proc)
|
||||||
concat '</form>', proc.binding
|
concat('</form>', proc.binding)
|
||||||
end
|
end
|
||||||
|
|
||||||
# Creates a scope around a specific model object like form_for, but doesn't create the form tags themselves. This makes
|
# Creates a scope around a specific model object like form_for, but doesn't create the form tags themselves. This makes
|
||||||
@ -141,10 +142,8 @@ def form_for(object_name, object, options = {}, &proc)
|
|||||||
# Note: This also works for the methods in FormOptionHelper and DateHelper that are designed to work with an object as base.
|
# Note: This also works for the methods in FormOptionHelper and DateHelper that are designed to work with an object as base.
|
||||||
# Like collection_select and datetime_select.
|
# Like collection_select and datetime_select.
|
||||||
def fields_for(object_name, object, options = {}, &proc)
|
def fields_for(object_name, object, options = {}, &proc)
|
||||||
raise ArgumentError, "fields_for requires a block!" unless block_given?
|
raise ArgumentError, "Missing block" unless block_given?
|
||||||
builder_klass = options[:builder] || FormBuilder
|
yield (options[:builder] || FormBuilder).new(object_name, object, self, options, proc)
|
||||||
form_builder = builder_klass.new(object_name, object, self, options, proc)
|
|
||||||
yield form_builder
|
|
||||||
end
|
end
|
||||||
|
|
||||||
# Returns an input tag of the "text" type tailored for accessing a specified attribute (identified by +method+) on an object
|
# Returns an input tag of the "text" type tailored for accessing a specified attribute (identified by +method+) on an object
|
||||||
|
@ -172,9 +172,9 @@ def form_remote_tag(options = {})
|
|||||||
|
|
||||||
# Works like form_remote_tag, but uses form_for semantics.
|
# Works like form_remote_tag, but uses form_for semantics.
|
||||||
def remote_form_for(object_name, object, options = {}, &proc)
|
def remote_form_for(object_name, object, options = {}, &proc)
|
||||||
concat form_remote_tag(options), proc.binding
|
concat(form_remote_tag(options), proc.binding)
|
||||||
fields_for(object_name, object, options, &proc)
|
fields_for(object_name, object, options, &proc)
|
||||||
concat '</form>', proc.binding
|
concat('</form>', proc.binding)
|
||||||
end
|
end
|
||||||
alias_method :form_remote_for, :remote_form_for
|
alias_method :form_remote_for, :remote_form_for
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user