You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When including a field within a custom element that uses Cp::elementSelectFieldHtml, certain changes to the field will cause Craft to create a draft even if the element isn't utilising trackChanges or canCreateDrafts or hasRevisions.
This leads to further errors as the element isn't set up to handle drafts and attempts to discard changes won't succeed.
Steps to reproduce
Create a new element type that overrides canView and canSave to return true, give the element a field layout and add a both text field and an element field e.g. Entries to the field layout. Giving the element a metafield using Cp::elementSelectFieldHtml also works.
Create a new element using the type in step 1 and make some changes to the text field to observe the lack of draft/change tracking.
Using the element field, select an element and then remove it. Removal of the element will trigger the creation of a draft.
As the draft is only created on removal of the element from the field I'm assuming it's Cp::elementSelectFieldHtml where the issue lies rather than my implementation but I could be wrong.
craftv4-element-select-bug.mov
Expected behavior
Changes to custom fields and metafields using Cp::elementSelectFieldHtml do not trigger draft creation.
Actual behavior
Changes to custom fields and metafields using Cp::elementSelectFieldHtml do trigger draft creation.
Craft CMS version
Craft Pro 4.0.2
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
The text was updated successfully, but these errors were encountered:
rynpsc
changed the title
[4.x]: Field using Cp::elementSelectFieldHtml force element draft creation
[4.x]: Fields using Cp::elementSelectFieldHtml force element draft creation
May 17, 2022
What happened?
Description
When including a field within a custom element that uses
Cp::elementSelectFieldHtml
, certain changes to the field will cause Craft to create a draft even if the element isn't utilisingtrackChanges
orcanCreateDrafts
orhasRevisions
.This leads to further errors as the element isn't set up to handle drafts and attempts to discard changes won't succeed.
Steps to reproduce
canView
andcanSave
to return true, give the element a field layout and add a both text field and an element field e.g. Entries to the field layout. Giving the element a metafield usingCp::elementSelectFieldHtml
also works.As the draft is only created on removal of the element from the field I'm assuming it's
Cp::elementSelectFieldHtml
where the issue lies rather than my implementation but I could be wrong.craftv4-element-select-bug.mov
Expected behavior
Changes to custom fields and metafields using Cp::elementSelectFieldHtml do not trigger draft creation.
Actual behavior
Changes to custom fields and metafields using Cp::elementSelectFieldHtml do trigger draft creation.
Craft CMS version
Craft Pro 4.0.2
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
The text was updated successfully, but these errors were encountered: