Review default_value/html_default_value/formatted_value/value in forms widgets #1366

Closed
bbenezech opened this Issue Oct 22, 2012 · 1 comment

Projects

None yet

2 participants

@bbenezech
Collaborator

value is meant to be called all the time, we should not rely on the default implicit rails behavior of calling the method name on the form's object.

Because it won't work with virtual columns.

Wrong

form.send field.view_helper, field.method_name, field.html_attributes.reverse_merge((hdv = field.html_default_value).nil? ? {} : { :value => hdv, :checked => hdv })

Good

form.send field.view_helper, field.method_name, field.html_attributes.reverse_merge((hdv = field.html_default_value).nil? ? { :value =>field.value, :checked => field.value } : { :value => hdv, :checked => hdv })

Or should we use formatted_value for that purpose and not rely on value, which is not a documented option ?
Check consistency.
Maybe adding a value method makes sense for a virtual column. But overriding a function does not fit well with the rest of RailsAdmin API.

Add a value option or use formatted_value uniformly ?

@bbenezech bbenezech was assigned Oct 22, 2012
@mshibuya
Collaborator

Virtual field support was introduced with 312e53d, by making formatted_value mandatory.

@mshibuya mshibuya closed this Nov 10, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment