-
Notifications
You must be signed in to change notification settings - Fork 332
Description
The subform columns usually inherit from update, when present, or core, as can be seen in the code:
def columns
# we want to delay initializing to the @core.update.columns set for as long as possible. but we have to eventually clone, or else have a configuration "leak"
unless @columns
if @core.actions.include? :update
@columns = @core.update.columns.clone
else
self.columns = @core.columns._inheritable
end
end
@columns
endThey can also be configured by themselves, in controller, like so:
conf.subform.columns = [:col1, col2, ...]All these behaviors result in having the exact same subform in both create/update situations.
I say a better behavior is to inherit columns from the create action when we deal with a new record or inherit from update action when we deal with an existing record.
Even better, we could have something like:
conf.subform.create that inherits from conf.create and
conf.subform.update inheriting from conf.update.
Here is an example gist that does such a customization: https://gist.github.com/1256348
Relevant parts are:
# _horizontal_subform_header.html.erb
config = active_scaffold_config_for(record.class)
columns = @record.new_record? ? config.create.columns : config.update.columns
columns.each :for => record.class, :crud_type => crud_type, :flatten => true do |column|
...
# _horizontal_subform_record.html.erb
columns = @record.new_record? ? config.create.columns : config.update.columns %>
columns.each :for => @record.class, :crud_type => crud_type, :flatten => true do |column| %>
...
If core members agree I could try and implement something like this.