Comments (1)
Matrix entries belong to their owner element, not a section, which is why the Section condition rule doesn’t work for them.
I don’t think it would make sense to loosen the condition rule up to include entries whose root-level owner is an entry that belongs to the selected section, for two reasons:
- It would be a breaking change in behavior, as some conditions could be using the same entry type for section entries and Matrix/CKEditor entries, and expecting that the condition rule would exclude the Matrix/CKEditor entries.
- It would open a can of worms, as Matrix/CKEditor fields can be added to other element types besides entries. What if you wanted to show a field based on whether the Matrix field is within a certain category group? Or a certain global set? Etc.
We’ll keep the use case in mind as we explore ways to improve conditions/conditional fields down the road, but in the meantime, I just added a new event for Craft 5.3, which you can use to supply your own conditional logic from a custom module:
use craft\base\FieldLayoutComponent;
use craft\elements\Entry;
use craft\events\DefineShowFieldLayoutComponentInFormEvent;
use craft\fieldlayoutelements\CustomField;
use yii\base\Event;
Event::on(
CustomField::class,
FieldLayoutComponent::EVENT_DEFINE_SHOW_IN_FORM,
function (DefineShowFieldLayoutComponentInFormEvent $event) {
/** @var CustomField $layoutElement */
$layoutElement = $event->sender;
if (
$layoutElement->field->handle === 'narrowWidth' &&
$event->element instanceof Entry &&
$event->element->field?->handle === 'contentBlocks'
) {
$owner = $event->element->getOwner();
if ($owner instanceof Entry) {
$event->showInForm = $owner->section?->handle === 'exhibits';
}
}
}
);
If you want to test that out, you can change your craftcms/cms
requirement in composer.json to:
"craftcms/cms": "5.3.x-dev as 5.3.0-alpha",
Then run composer update
.
from cms.
Related Issues (20)
- [5.x]: Unusable Icons Displayed in Icon Field HOT 3
- [5.x]: The "Edited" tag in the breadcrumbs bar disappears on page reload HOT 2
- [5.x]: Dropdown field marked as dirty when opening slideout HOT 6
- [5.x]: Unable to Add the Same Image Field Multiple Times HOT 3
- [4.x]: Search index algorithm not functioning as expected HOT 1
- [5.x]: Sidebar overlap with entry index in some screen widths HOT 1
- [5.x]: Craft 4 to 5 staging deploy fails with "Unknown column 'fields.groupId' in 'field list'" HOT 1
- [5.x]: Nested matrix entry types disappear when page is reloaded after making changes HOT 2
- [4.x]: `Entry::EVENT_AFTER_SAVE` executes before any changes are committed to the database HOT 3
- Disappearing Assets HOT 1
- [5.x]: postgres exception during upgrade from v4 to v5 HOT 1
- Element Editor Slide Out - Will Not Save Updates [4.9.6]: HOT 17
- [5.x]: Sidebar toggle broken for several items in 5.2.4 HOT 2
- [5.x]: Primary site language not respected when replacing missing translations HOT 2
- [5.x]: GraphQL type name collision
- [5.x]: GraphQL mutation for nested elements does not accept entry `title`s
- [5.2.2]: Some getValueSql database queries fail since update HOT 1
- [5.x]: "Delete (with descendants)" element action doesn't delete descendants HOT 1
- Unknown command '\-' on database import & glitchy download database progress bar. [4.x]: HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from cms.