diff --git a/core/modules/comment/src/Plugin/Field/FieldType/CommentItem.php b/core/modules/comment/src/Plugin/Field/FieldType/CommentItem.php index 24293f908375cc92bc3133c4ef9bd19e49194b08..38ce505adf65899159ee9ba2d426e5552fadf4ef 100644 --- a/core/modules/comment/src/Plugin/Field/FieldType/CommentItem.php +++ b/core/modules/comment/src/Plugin/Field/FieldType/CommentItem.php @@ -11,6 +11,7 @@ use Drupal\comment\Entity\CommentType; use Drupal\Core\Field\FieldStorageDefinitionInterface; use Drupal\Core\Form\FormStateInterface; +use Drupal\Core\Render\Element; use Drupal\Core\TypedData\DataDefinition; use Drupal\Core\Field\FieldItemBase; use Drupal\Core\Session\AnonymousUserSession; @@ -106,21 +107,13 @@ public function fieldSettingsForm(array $form, FormStateInterface $form_state) { $anonymous_user = new AnonymousUserSession(); - $element['comment'] = array( - '#type' => 'details', - '#title' => t('Comment form settings'), - '#open' => TRUE, - '#attached' => array( - 'library' => array('comment/drupal.comment'), - ), - ); - $element['comment']['default_mode'] = array( + $element['default_mode'] = array( '#type' => 'checkbox', '#title' => t('Threading'), '#default_value' => $settings['default_mode'], '#description' => t('Show comment replies in a threaded list.'), ); - $element['comment']['per_page'] = array( + $element['per_page'] = array( '#type' => 'number', '#title' => t('Comments per page'), '#default_value' => $settings['per_page'], @@ -129,7 +122,7 @@ public function fieldSettingsForm(array $form, FormStateInterface $form_state) { '#max' => 1000, '#step' => 10, ); - $element['comment']['anonymous'] = array( + $element['anonymous'] = array( '#type' => 'select', '#title' => t('Anonymous commenting'), '#default_value' => $settings['anonymous'], @@ -140,12 +133,12 @@ public function fieldSettingsForm(array $form, FormStateInterface $form_state) { ), '#access' => $anonymous_user->hasPermission('post comments'), ); - $element['comment']['form_location'] = array( + $element['form_location'] = array( '#type' => 'checkbox', '#title' => t('Show reply form on the same page as comments'), '#default_value' => $settings['form_location'], ); - $element['comment']['preview'] = array( + $element['preview'] = array( '#type' => 'radios', '#title' => t('Preview comment'), '#default_value' => $settings['preview'], diff --git a/core/modules/comment/src/Tests/CommentNonNodeTest.php b/core/modules/comment/src/Tests/CommentNonNodeTest.php index ffe1b56ee55f43577dfd76a75d02932aa6428fb8..65271a1a6725dcb9a098192a9781e918765c6daa 100644 --- a/core/modules/comment/src/Tests/CommentNonNodeTest.php +++ b/core/modules/comment/src/Tests/CommentNonNodeTest.php @@ -360,12 +360,16 @@ function testCommentFunctionality() { $this->assertNoFieldChecked('edit-default-value-input-comment-0-status-1'); $this->assertFieldChecked('edit-default-value-input-comment-0-status-2'); // Test comment option change in field settings. - $edit = array('default_value_input[comment][0][status]' => CommentItemInterface::CLOSED); + $edit = array( + 'default_value_input[comment][0][status]' => CommentItemInterface::CLOSED, + 'field[settings][anonymous]' => COMMENT_ANONYMOUS_MAY_CONTACT, + ); $this->drupalPostForm(NULL, $edit, t('Save settings')); $this->drupalGet('entity_test/structure/entity_test/fields/entity_test.entity_test.comment'); $this->assertNoFieldChecked('edit-default-value-input-comment-0-status-0'); $this->assertFieldChecked('edit-default-value-input-comment-0-status-1'); $this->assertNoFieldChecked('edit-default-value-input-comment-0-status-2'); + $this->assertFieldByName('field[settings][anonymous]', COMMENT_ANONYMOUS_MAY_CONTACT); // Add a new comment-type. $bundle = CommentType::create(array(