Problem/Motivation

When creating a Node content type the "Create new revision" checkbox is ticket, but doesn't save as set.

Proposed resolution

Set the value as well as the default_value

Remaining tasks

User interface changes

API changes

Data model changes

Related Workbench Moderation issue

#2852063: Enforced "Create new revision" isn't saved to the config

Comments

acbramley created an issue. See original summary.

Version: 8.3.x-dev » 8.4.x-dev

Drupal 8.3.6 was released on August 2, 2017 and is the final full bugfix release for the Drupal 8.3.x series. Drupal 8.3.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.4.0 on October 4, 2017. (Drupal 8.4.0-alpha1 is available for testing.)

Bug reports should be targeted against the 8.4.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.5.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.4.x-dev » 8.5.x-dev

Drupal 8.4.4 was released on January 3, 2018 and is the final full bugfix release for the Drupal 8.4.x series. Drupal 8.4.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.5.0 on March 7, 2018. (Drupal 8.5.0-alpha1 is available for testing.)

Bug reports should be targeted against the 8.5.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.6.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

timmillwood’s picture

Issue summary: View changes
Status: Active » Needs review
StatusFileSize
new1 KB
new1.83 KB

Here's a patch for this.

The last submitted patch, 4: 2865223-4-test-only.patch, failed testing. View results

amateescu’s picture

+++ b/core/modules/content_moderation/src/Entity/Handler/NodeModerationHandler.php
@@ -55,6 +55,7 @@ public function enforceRevisionsEntityFormAlter(array &$form, FormStateInterface
     $form['workflow']['options']['#default_value']['revision'] = 'revision';
+    $form['workflow']['options']['#value']['revision'] = 'revision';

Can we remove the #default_value assignment if we're using #value directly?

timmillwood’s picture

StatusFileSize
new846 bytes
new1.83 KB

Manually tested, and we can.

amateescu’s picture

Status: Needs review » Reviewed & tested by the community

Nice, looks good to me.

berdir’s picture

Makes me wonder if a #disabled checkbox that is by default checked should be handled somehow in the form system automatically? I think this happens because browsers don't send the value for disabled form elements.

alexpott’s picture

Status: Reviewed & tested by the community » Fixed

Committed and pushed 6f4affd1e6 to 8.6.x and 10e60869b0 to 8.5.x. Thanks!

  • alexpott committed 6f4affd on 8.6.x
    Issue #2865223 by timmillwood, amateescu: Node type form alter sets new...

  • alexpott committed 10e6086 on 8.5.x
    Issue #2865223 by timmillwood, amateescu: Node type form alter sets new...

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.