Problem/Motivation

Many Drupal site builders habitually remove the default body field, especially when using a module like Paragraphs. For these Drupal power users, it would be convenient if the body field was only added automatically when using the standard install profile but not in the minimal install profile.

Proposed resolution

Add a new setting to the node module which controls whether a body field is automatically added to new content types.

User interface changes

None.

API changes

None.

Data model changes

A new configuration value will be added to the node settings configuration object.

Release notes snippet

A body field will not be automatically added to new content types on new sites that do not use the standard install profile. Additionally, users may add $config['node.settings']['add_default_body_field'] = FALSE to their settings file to prevent a body field from being added to new content types on their existing sites.

Issue fork drupal-3270198

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

  • 3270198-do-not-automatically Comparechanges, plain diff MR !1993
  • 9.2.x Comparecompare
  • 9.3.x Comparecompare
  • 9.4.x Comparecompare
  • 10.0.x Comparecompare

Comments

gabesullice created an issue. See original summary.

gabesullice’s picture

Issue tags: +Needs tests
StatusFileSize
new2.52 KB
gabesullice’s picture

gabesullice’s picture

StatusFileSize
new173 bytes
new2.84 KB

Many tests are failing because they implicitly rely on the default body field. To minimize the disruption that this may cause in contrib, this patch re-enables the default body field in the testing profile. Hopefully that will fix most of the failing tests 🤞

jungle’s picture

+1 to this feature. I am afraid that needs a CR and tests. Thanks!

(Edited: as the Needs tests tag added )

gabesullice’s picture

Issue tags: +Needs change record

DieterHolvoet made their first commit to this issue’s fork.

dieterholvoet’s picture

StatusFileSize
new3.24 KB

I changed the post update hook to only change the config value if it wasn't set before. This can happen if you run the update hook locally, commit the config change and later deploy that to other environments. I also created a MR with the existing progress together with this change, and attached an updated patch for easier inclusion in Composer projects.

Version: 9.4.x-dev » 9.5.x-dev

Drupal 9.4.0-alpha1 was released on May 6, 2022, which means new developments and disruptive changes should now be targeted for the 9.5.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.5.x-dev » 10.1.x-dev

Drupal 9.5.0-beta2 and Drupal 10.0.0-beta2 were released on September 29, 2022, which means new developments and disruptive changes should now be targeted for the 10.1.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

dieterholvoet’s picture

Status: Active » Needs work
danielveza’s picture

Did a quick code review in the MR. I think the messager needs to be moved outside the if statement in NodeForm.

dieterholvoet’s picture

I rebased the branch against 10.1.x and moved the message outside the if statement.

Version: 10.1.x-dev » 11.x-dev

Drupal core is moving towards using a “main” branch. As an interim step, a new 11.x branch has been opened, as Drupal.org infrastructure cannot currently fully support a branch named main. New developments and disruptive changes should now be targeted for the 11.x branch, which currently accepts only minor-version allowed changes. For more information, see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

dieterholvoet’s picture

Status: Needs work » Closed (outdated)
Related issues: +#3488742: Stop calling node_add_body_field() from NodeTypeForm

This has been fixed in #3488742: Stop calling node_add_body_field() from NodeTypeForm: now the body field is never being added anymore automatically.