craftcms / craftcms/cms

[5.x]: Unable to change field handle for a global field

Open
#16,963 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug
Dominant language
PHP
Stars
3.6k
Forks
705
Avg merge
1d 5h
Merged PRs (30d)
134

Description

What happened?
Description

When I add an existing field to a global, I am unable to change the fieldHandle.

Steps to reproduce
  1. Take an existing field, in my case is an asset field, and drag it into the field layout within a globals section.
  2. Save that globals section, successfully.
  3. Click the "..." next to that asset field and give it a new contentHandle. (It doesn't matter what you change it to)
  4. Click "Apply"... looks successful
  5. Click Save on the global page.
  6. Met with InvalidFieldException

Image

Expected behavior

This should give the instance of the field the desired name, as it does correctly in Entry Types.

Actual behavior

Throws above exception.

Craft CMS version

5.6.12

PHP version

8.2.18

Operating system and version

No response

Database type and version

No response

Image driver and version

No response

Installed plugins and versions

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the issue in Craft CMS 5.6.12 by adding an existing asset field to a globals section, changing its contentHandle, and saving the global. Start from the resulting InvalidFieldException and trace the global field-save path. Done means the field instance accepts the changed handle and the globals section saves successfully, as it does for entry types.

Written by the indexing model from the issue text.

Assessment

Tech stack
php
Domain
backend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.