You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When creating a custom form builder by subclassing ActionView::Helpers::FormBuilder, objectify_options is not called on any of the option parameters in any methods defined unless the user specifically knows about this private method
For example, my own simple custom form builder used to look like this.
The problem is that since objectify_options was not not called on the html_options variable, the "value" field (which when the form is called in an update action inside the controller would contain the value of the attribute in the model by default) wasn't being filled. To fix this, a user has to explicitly call objectify_options on the options variable
, and in that source there is no mention of using objectify_options, nor is it being called.
tl;dr It is not obvious (even in the slightest) that a user has to use objectify_options on the options parameter to mimic the default form builders methods when creating their own form builder methods.
Either the documentation needs to make this very clear, or this behavior should be automatic when using custom form builders by subclassing ActionView::Helpers::FormBuilder
The text was updated successfully, but these errors were encountered:
wangjohn
added a commit
to wangjohn/rails
that referenced
this issue
Apr 7, 2013
When creating a custom form builder by subclassing
ActionView::Helpers::FormBuilder
, objectify_options is not called on any of the option parameters in any methods defined unless the user specifically knows about this private methodFor example, my own simple custom form builder used to look like this.
The problem is that since
objectify_options
was not not called on thehtml_options
variable, the "value" field (which when the form is called in an update action inside the controller would contain the value of the attribute in the model by default) wasn't being filled. To fix this, a user has to explicitly callobjectify_options
on the options variableThis workflow is both very DRY and obscure/confusing.
objectify_options
is only documented here (http://apidock.com/rails/ActionView/Helpers/FormBuilder/objectify_options) with no comments and isn't mentioned anywhere else. Using the above as an example, one would look hererails/actionpack/lib/action_view/helpers/form_helper.rb
Line 689 in 4886991
tl;dr It is not obvious (even in the slightest) that a user has to use objectify_options on the options parameter to mimic the default form builders methods when creating their own form builder methods.
Either the documentation needs to make this very clear, or this behavior should be automatic when using custom form builders by subclassing
ActionView::Helpers::FormBuilder
The text was updated successfully, but these errors were encountered: