The Entries fieldtype configuration lets you select Sources which are Sections. I've had several cases where I wanted to allow users to only be able to select one or two EntryTypes within a Section.
Example: An 'Events' section that has 3 EntryTypes: Webinar, In-Person, Holidays. Currently, you'd have to create a field and define an Instruction that says to only pick Holiday events even though the UI allows them to select anything.

I also think this is a very useful feature. I mostly have a usecase for it in structures, where there is often a real difference between a parent and it's children. But in general I miss this feature regularly
I would love to add to this a way to only select entries with a certain status (Only published entries for example)
In the mean time before this gets implemented in core, it's actually really easy and low-risk to do it yourself in a custom module! For example, I have a structure "Pages" with some pages being product pages. The following does two things:
if (Craft::$app->getRequest()->getIsCpRequest()) {
// Allow selecting only product pages
Event::on(Entry::class, Element::EVENT_REGISTER_SOURCES, function(RegisterElementSourcesEvent $event) {
$newSource = [
'key' => 'view:products',
'label' => 'Product Pages',
'criteria' => [
'sectionId' => [8], // Pages section ID
'typeId' => [26], // Product Page entry type
'editable' => true // Make sure the current user has permission to edit
]
];
$event->sources[] = $newSource;
});
}
This is a little known feature that adds a ton of value to the CMS - this is also really helpful for building "audit" sections in the CP. For example, for another client, while entering products, I wanted to be able to allow them to quickly view all products without thumbnails. The code above can be easily tweaked to filter by fields values, since it's just parsed to an element query.
I just added a new event to craft\fields\BaseRelationField for the next release (3.4.16), which makes it possible to customize relational fields’ element criteria right at the field level.
Going with the OP example:
use craft\events\ElementCriteriaEvent;
use craft\fields\Entries;
use yii\base\Event;
// Only allow Holiday entries to be selected
Event::on(
Entries::class,
Entries::EVENT_DEFINE_SELECTION_CRITERIA,
function(ElementCriteriaEvent $e) {
/** @var Entries $field */
$field = $e->sender;
if ($field->handle === 'relatedHolidays') {
$e->criteria['type'] = 'holiday';
}
}
);
(Still planning on making this a core feature down the road, so not going to close the issue.)
Craft 3.4.16 is out now with that new event.
Most helpful comment
I just added a new event to
craft\fields\BaseRelationFieldfor the next release (3.4.16), which makes it possible to customize relational fields’ element criteria right at the field level.Going with the OP example:
(Still planning on making this a core feature down the road, so not going to close the issue.)