What happened?
When a nested entry in a matrix field is modified, a draft is automatically created. When the draft is saved, however, calling ElementHelper::isDraft($element) returns false.
This appears to be caused due to getIsDraft() being called on the root element, rather than on the element itself.
|
return static::rootElement($element)->getIsDraft(); |
I imagine this could be solved as follows:
return $element->getIsDraft() || static::rootElement($element)->getIsDraft();
Note that the ElementHelper::isDraftOrRevision() and possibly also the ElementHelper::isRevision() method should be updated accordingly.
Steps to reproduce
- Listen for a save event on a nested entry in a matrix field.
- Modify the nested entry so that it automatically creates a draft (without hitting the save button).
- Check the value of
ElementHelper::isDraft($element).
Expected behavior
ElementHelper::isDraft($element) should return true.
Actual behavior
ElementHelper::isDraft($element) returns false.
Craft CMS version
5.2.5
PHP version
No response
Operating system and version
No response
Database type and version
No response
Image driver and version
No response
Installed plugins and versions
No response
What happened?
When a nested entry in a matrix field is modified, a draft is automatically created. When the draft is saved, however, calling
ElementHelper::isDraft($element)returnsfalse.This appears to be caused due to
getIsDraft()being called on the root element, rather than on the element itself.cms/src/helpers/ElementHelper.php
Line 490 in 37356eb
I imagine this could be solved as follows:
Note that the
ElementHelper::isDraftOrRevision()and possibly also theElementHelper::isRevision()method should be updated accordingly.Steps to reproduce
ElementHelper::isDraft($element).Expected behavior
ElementHelper::isDraft($element)should returntrue.Actual behavior
ElementHelper::isDraft($element)returnsfalse.Craft CMS version
5.2.5
PHP version
No response
Operating system and version
No response
Database type and version
No response
Image driver and version
No response
Installed plugins and versions
No response