Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions app/models/locomotive/concerns/content_type/default_values.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,23 @@ def set_group_by
end
end

def set_group_by
# Use .present? to check for not nil AND not empty string
if @group_by.present
field = self.find_entries_custom_field(@group_by)
# A valid field name was provided, and the field was found
if field
self.group_by_field_id = field._id
# A field name was provided, but it's invalid or not found
else
self.group_by_field_id = nil
end
# @group_by is nil or an empty string (intention to unset grouping)
else
self.group_by_field_id = nil
end
end

def set_label_field
if @new_label_field_name.present?
self.label_field_id = self.entries_custom_fields.detect { |f| f.name == @new_label_field_name.underscore }.try(:_id)
Expand Down