2

I have some entries with a multi-select field called "gallery". We can choose many images to this field.

I have a given image, how can I query entries whose "gallery" contains this given image? Thx!

I have tried like this with no success:

Entry::find()
  ->section($section)
  ->galleryImages('contains' . $image->id)
  ->all();
3

There is a related to parameter you can use

Entry::find()
  ->section($section)
  ->relatedTo(['targetElement' => $image->id, 'field' => 'galleryImages')
  ->all();

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.