Skip to content

5.x Filtering against a field that's shared across many entry types is cumbersome #16892

Closed Answered by brandonkelly
johnrich85 asked this question in Ideas
Discussion options

You must be logged in to vote

Most field types provide their own element query params that simplify filtering results by them.

For example, if this is a Plain Text field, you could do:

$elementQuery->myFieldHandle('not abc');
// or:
$elementQuery->myFieldHandle(['not', 'abc']);

And as of Craft 5.6, you can now refer to custom field handles within conditions passed to where() (et al.), and they will automatically get replaced with references to the individual sub-JSON values.

$elementQuery->andWhere(['not', ['myFieldHandle' => 'abc']]);

(Same goes for orderBy and select methods - #16157.)

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by brandonkelly
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Ideas
Labels
None yet
2 participants