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
bodyfield 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'] = FALSEto their settings file to prevent abodyfield from being added to new content types on their existing sites.
| Comment | File | Size | Author |
|---|---|---|---|
| #9 | 3270198-9.patch | 3.24 KB | dieterholvoet |
Issue fork drupal-3270198
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:
Comments
Comment #2
gabesulliceComment #3
gabesulliceComment #4
gabesulliceMany 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
testingprofile. Hopefully that will fix most of the failing tests 🤞Comment #5
jungle+1 to this feature. I am afraid that needs a CR and
tests. Thanks!(Edited: as the Needs tests tag added )
Comment #6
gabesulliceComment #9
dieterholvoet commentedI 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.
Comment #12
dieterholvoet commentedComment #13
danielvezaDid a quick code review in the MR. I think the messager needs to be moved outside the if statement in NodeForm.
Comment #14
dieterholvoet commentedI rebased the branch against 10.1.x and moved the message outside the if statement.
Comment #16
dieterholvoet commentedThis has been fixed in #3488742: Stop calling node_add_body_field() from NodeTypeForm: now the body field is never being added anymore automatically.