Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[5.x]: Plain text field with handle "sectionId" returns null value after migration from Craft 4 to Craft 5 #15923

Closed
sydneyhaggard opened this issue Oct 18, 2024 · 2 comments
Assignees
Labels

Comments

@sydneyhaggard
Copy link

What happened?

Description

Plain text field named "Section Id" with handle "sectionId" does not render input data from CMS backend inside rendered template. This previously worked when my project was running Craft 4, but returns a null value after migrating project to Craft 5. Appears to be a potential conflict with a protected handle in the Craft 5 Class reference on entries. Changing handle of field to "sectionID" works and bypasses this issue.

Steps to reproduce

  1. Spin up Craft 4 project.
  2. Create matrix field and matrix entry.
  3. Create plain text field called "Section Id" with handle "sectionId". Add "Section Id" to matrix entry and template.
    Image
    Image
  4. Add "Section Id" field to entry and set a value for the field.
    Image
  5. Save entry with "Section Id" field value.
  6. Verify in template that "sectionId" handle outputs value as expected on frontend template.
    Image
  7. Migrate site from Craft 4 to Craft 5.
  8. Verify "Section Id" field still exists with handle "sectionId"
    Image
  9. Verify "Section Id" is available on the entry backend and has content saved to the field.
    Image
  10. Verify "Section Id" does NOT render on front end template.
    Image
  11. Navigate back to field in Settings.
  12. Change handle of "sectionId" to "sectionID". Modify entry template to match.
    Image
    Image
  13. Verify data renders on front end template.
    Image

Expected behavior

For Section Id field with handle "sectionId" to render entered value on backend on front end template.

Actual behavior

Section Id field with handle "sectionId" returns with null value and does not render on front end template.

Craft CMS version

5.4.8

PHP version

8.2

Operating system and version

MacOS Sequoia 15.0.1

Database type and version

mariadb:10.5

Image driver and version

No response

Installed plugins and versions

  • CKEditor by Pixel & Tonic. v4.2.0
  • Embedded Assets by Spicy Web. v5.1.2
  • SEO by Ether Creative. v5.0.0
@i-just
Copy link
Contributor

i-just commented Oct 22, 2024

Hi, thanks for getting in touch and clear replication steps!

This happens in v5 because matrix blocks are now entries; all entries have a sectionId property, which, for the nested entries (like matrix “blocks”), is null. Renaming that handle is the way to go. I just raised a PR to make the sectionId field handle reserved in the context of an Entry Type.

@brandonkelly
Copy link
Member

Craft 5.4.9 is out now, where sectionId is now a reserved field handle for entry types.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants