Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Relational field conditions #10393

Merged
merged 2 commits into from
Jan 21, 2022

Conversation

brandonkelly
Copy link
Member

@brandonkelly brandonkelly commented Jan 21, 2022

Description

This adds new condition settings to Assets, Entries, and Users fields, which can be used to further limit which elements should be relatable, beyond the field types’ existing settings.

For example, the “Selectable Entries Condition” setting on Entries fields could be used to limit the relatable entries to only those of a certain entry type:

The “Selectable Entries Condition” setting on an Entries field, with an “Entry Type” rule applied that limits the relatable entries to those of type “Link”.

Plugin-provided relational fields can add their own condition setting by overriding BaseRelationField::createSelectionCondition() method:

protected function createSelectionCondition(): ?ElementCondition
{
    $condition = Entry::createCondition();
    $condition->queryParams = ['section', 'sectionId'];
    return $condition;
}

Related issues

@linear
Copy link

linear bot commented Jan 21, 2022

DEV-78 Relational field conditions

Relational fields should include condition builders for fine-tuning which elements should be relatable, using a condition builder for defining element query params.

(Only params that reference things in the project config can be used, since field settings are also stored in the project config.)

@brandonkelly brandonkelly merged commit 662b285 into 4.0 Jan 21, 2022
@brandonkelly brandonkelly deleted the feature/dev-78-relational-field-conditions branch January 21, 2022 08:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant