craftcms / craftcms/cms

Error deleting a field that was created through a migration

Open
#5,768 10 comments 2 reactions 1 assignee View on GitHub

@andris-sevcenko is already working on this.

Since Mar 19, 2020.

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

Description

Description

When trying to delete field I created through a migration, the following error is thrown:

Argument 2 passed to craft\services\Fields::applyFieldSave() must be of the type array, null given, called in /Users/jhenckens/Sites/vigwec3/vendor/craftcms/cms/src/services/Fields.php on line 826

When I try to validate the field no errors are shown and I can use it like any other field.
I'm creating the field like this:

$latitude = new PlainText();
$latitude->handle = 'latitude';
$latitude->name = 'Latitude';
$latitude->groupId = 2;
Craft::$app->getFields()->saveField($latitude);

Deleting a field that was created through the CP works.

Steps to reproduce
  1. Create a field through a migration
  2. Try to delete that same field
Additional info
  • Craft version: 3.4.9
  • PHP version: 7.3.
  • Database driver & version: 5.7.26

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.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.