Skip to content

Irrelevant custom fields required in site settings #1124

@brian-kephart

Description

@brian-kephart

Currently, when editing the settings for a site, a bunch of irrelevant custom field groups are being shown in the site settings. These field groups are meant to act on certain types of content owned by the site, but not on the site itself. However, since these field groups include required fields, their presence makes it impossible to save the relevant changes to my site settings because this irrelevant data is not filled in.

Steps to reproduce:

  1. Make a custom field group for any type of content within a site. Include a required field. In the "Where to display this group" select box, select anything besides Site settings.
  2. Navigate to /admin/settings/site, click on the Custom Configurations tab, and view the custom fields that should not be there.

Analysis:

The view renders a collection from Site#get_field_groups:

<% groups = @site.get_field_groups %>

<%= render partial: "camaleon_cms/admin/settings/custom_fields/render", locals: {record: @site, field_groups: groups} %>

Site#get_field_groups calls Site#custom_field_groups:

Site#custom_field_groups uses the foreign key CustomFieldGroup#parent_id:

has_many :custom_field_groups, class_name: 'CamaleonCms::CustomFieldGroup', foreign_key: :parent_id,
dependent: :destroy

And that's where I think the problem lies, because ultimately Site#get_field_groups is returning custom field groups where the site is associated as the parent, rather than as the object of the custom field group.

However, I don't know yet which course of action is most appropriate:

  1. Modify Site#get_field_groups to use the the object foreign key relationship, instead of parent
  2. Use something besides Site#get_field_groups in the view
  3. Something else

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions