Loading core/lib/Drupal/Core/Field/FieldConfigBase.php +0 −6 Original line number Diff line number Diff line Loading @@ -6,7 +6,6 @@ use Drupal\Core\Entity\EntityStorageInterface; use Drupal\Core\Entity\FieldableEntityInterface; use Drupal\Core\Field\TypedData\FieldItemDataDefinition; use Drupal\field\Entity\FieldStorageConfig; /** * Base class for configurable field definitions. Loading Loading @@ -475,11 +474,6 @@ public function __sleep() { // recalculated. unset($properties['itemDefinition'], $properties['original']); // Field storage can be recalculated if it's not new. if (array_key_exists('fieldStorage', $properties) && $properties['fieldStorage'] instanceof FieldStorageConfig && !$properties['fieldStorage']->isNew()) { unset($properties['fieldStorage']); } return array_keys($properties); } Loading core/lib/Drupal/Core/Form/SubformState.php +18 −3 Original line number Diff line number Diff line Loading @@ -34,8 +34,10 @@ class SubformState extends FormStateDecoratorBase implements SubformStateInterfa * The subform's parent form. * @param \Drupal\Core\Form\FormStateInterface $parent_form_state * The parent form state. * @param \Drupal\Core\Form\FormInterface|null $subformFormObject * The subform form object when it's not the same as the parent form. */ protected function __construct(array &$subform, array &$parent_form, FormStateInterface $parent_form_state) { protected function __construct(array &$subform, array &$parent_form, FormStateInterface $parent_form_state, protected readonly ?FormInterface $subformFormObject = NULL) { $this->decoratedFormState = $parent_form_state; $this->parentForm = $parent_form; $this->subform = $subform; Loading @@ -50,11 +52,13 @@ protected function __construct(array &$subform, array &$parent_form, FormStateIn * The subform's parent form. * @param \Drupal\Core\Form\FormStateInterface $parent_form_state * The parent form state. * @param \Drupal\Core\Form\FormInterface|null $subform_form_object * The subform form object when it's not the same as the parent form. * * @return static */ public static function createForSubform(array &$subform, array &$parent_form, FormStateInterface $parent_form_state) { return new static($subform, $parent_form, $parent_form_state); public static function createForSubform(array &$subform, array &$parent_form, FormStateInterface $parent_form_state, ?FormInterface $subform_form_object = NULL) { return new static($subform, $parent_form, $parent_form_state, $subform_form_object); } /** Loading Loading @@ -151,4 +155,15 @@ public function setErrorByName($name, $message = '') { return $this; } /** * {@inheritdoc} */ public function getFormObject() { if ($this->subformFormObject) { return $this->subformFormObject; } return parent::getFormObject(); } } core/modules/comment/tests/src/Functional/CommentFieldsTest.php +4 −5 Original line number Diff line number Diff line Loading @@ -162,8 +162,7 @@ public function testCommentFieldCreate() { // Try to save the comment field without selecting a comment type. $edit = []; $this->drupalGet('admin/config/people/accounts/add-storage/user/field_user_comment'); $this->submitForm($edit, 'Continue'); $this->submitForm($edit, 'Update settings'); // We should get an error message. $this->assertSession()->pageTextContains('The submitted value in the Comment type element is not allowed.'); Loading @@ -178,10 +177,10 @@ public function testCommentFieldCreate() { // Select a comment type and try to save again. $edit = [ 'settings[comment_type]' => 'user_comment_type', 'field_storage[subform][settings][comment_type]' => 'user_comment_type', ]; $this->drupalGet('admin/config/people/accounts/add-storage/user/field_user_comment'); $this->submitForm($edit, 'Continue'); $this->drupalGet('admin/config/people/accounts/add-field/user/field_user_comment'); $this->submitForm($edit, 'Update settings'); // We shouldn't get an error message. $this->assertSession()->pageTextNotContains('The submitted value in the Comment type element is not allowed.'); Loading core/modules/comment/tests/src/Functional/CommentNonNodeTest.php +1 −3 Original line number Diff line number Diff line Loading @@ -277,8 +277,6 @@ public function testCommentFunctionality() { $this->assertSession()->statusCodeEquals(200); $this->assertSession()->fieldNotExists('edit-default-value-input-comment-und-0-status-0'); // Test that field to change cardinality is not available. $this->drupalGet('entity_test/structure/entity_test/fields/entity_test.entity_test.comment/storage'); $this->assertSession()->statusCodeEquals(200); $this->assertSession()->fieldNotExists('cardinality_number'); $this->assertSession()->fieldNotExists('cardinality'); Loading Loading @@ -439,7 +437,7 @@ public function testCommentFunctionality() { // Add a new comment field. $storage_edit = [ 'settings[comment_type]' => 'foobar', 'field_storage[subform][settings][comment_type]' => 'foobar', ]; $this->fieldUIAddNewField('entity_test/structure/entity_test', 'foobar', 'Foobar', 'comment', $storage_edit); Loading core/modules/datetime/tests/src/Functional/DateTimeFieldTest.php +2 −2 Original line number Diff line number Diff line Loading @@ -932,8 +932,8 @@ public function testDateStorageSettings() { ]; $this->drupalGet('node/add/date_content'); $this->submitForm($edit, 'Save'); $this->drupalGet('admin/structure/types/manage/date_content/fields/node.date_content.' . $field_name . '/storage'); $this->assertSession()->elementsCount('xpath', "//*[@id='edit-settings-datetime-type' and contains(@disabled, 'disabled')]", 1); $this->drupalGet('admin/structure/types/manage/date_content/fields/node.date_content.' . $field_name); $this->assertSession()->elementsCount('xpath', "//*[@name='field_storage[subform][settings][datetime_type]' and contains(@disabled, 'disabled')]", 1); } } Loading
core/lib/Drupal/Core/Field/FieldConfigBase.php +0 −6 Original line number Diff line number Diff line Loading @@ -6,7 +6,6 @@ use Drupal\Core\Entity\EntityStorageInterface; use Drupal\Core\Entity\FieldableEntityInterface; use Drupal\Core\Field\TypedData\FieldItemDataDefinition; use Drupal\field\Entity\FieldStorageConfig; /** * Base class for configurable field definitions. Loading Loading @@ -475,11 +474,6 @@ public function __sleep() { // recalculated. unset($properties['itemDefinition'], $properties['original']); // Field storage can be recalculated if it's not new. if (array_key_exists('fieldStorage', $properties) && $properties['fieldStorage'] instanceof FieldStorageConfig && !$properties['fieldStorage']->isNew()) { unset($properties['fieldStorage']); } return array_keys($properties); } Loading
core/lib/Drupal/Core/Form/SubformState.php +18 −3 Original line number Diff line number Diff line Loading @@ -34,8 +34,10 @@ class SubformState extends FormStateDecoratorBase implements SubformStateInterfa * The subform's parent form. * @param \Drupal\Core\Form\FormStateInterface $parent_form_state * The parent form state. * @param \Drupal\Core\Form\FormInterface|null $subformFormObject * The subform form object when it's not the same as the parent form. */ protected function __construct(array &$subform, array &$parent_form, FormStateInterface $parent_form_state) { protected function __construct(array &$subform, array &$parent_form, FormStateInterface $parent_form_state, protected readonly ?FormInterface $subformFormObject = NULL) { $this->decoratedFormState = $parent_form_state; $this->parentForm = $parent_form; $this->subform = $subform; Loading @@ -50,11 +52,13 @@ protected function __construct(array &$subform, array &$parent_form, FormStateIn * The subform's parent form. * @param \Drupal\Core\Form\FormStateInterface $parent_form_state * The parent form state. * @param \Drupal\Core\Form\FormInterface|null $subform_form_object * The subform form object when it's not the same as the parent form. * * @return static */ public static function createForSubform(array &$subform, array &$parent_form, FormStateInterface $parent_form_state) { return new static($subform, $parent_form, $parent_form_state); public static function createForSubform(array &$subform, array &$parent_form, FormStateInterface $parent_form_state, ?FormInterface $subform_form_object = NULL) { return new static($subform, $parent_form, $parent_form_state, $subform_form_object); } /** Loading Loading @@ -151,4 +155,15 @@ public function setErrorByName($name, $message = '') { return $this; } /** * {@inheritdoc} */ public function getFormObject() { if ($this->subformFormObject) { return $this->subformFormObject; } return parent::getFormObject(); } }
core/modules/comment/tests/src/Functional/CommentFieldsTest.php +4 −5 Original line number Diff line number Diff line Loading @@ -162,8 +162,7 @@ public function testCommentFieldCreate() { // Try to save the comment field without selecting a comment type. $edit = []; $this->drupalGet('admin/config/people/accounts/add-storage/user/field_user_comment'); $this->submitForm($edit, 'Continue'); $this->submitForm($edit, 'Update settings'); // We should get an error message. $this->assertSession()->pageTextContains('The submitted value in the Comment type element is not allowed.'); Loading @@ -178,10 +177,10 @@ public function testCommentFieldCreate() { // Select a comment type and try to save again. $edit = [ 'settings[comment_type]' => 'user_comment_type', 'field_storage[subform][settings][comment_type]' => 'user_comment_type', ]; $this->drupalGet('admin/config/people/accounts/add-storage/user/field_user_comment'); $this->submitForm($edit, 'Continue'); $this->drupalGet('admin/config/people/accounts/add-field/user/field_user_comment'); $this->submitForm($edit, 'Update settings'); // We shouldn't get an error message. $this->assertSession()->pageTextNotContains('The submitted value in the Comment type element is not allowed.'); Loading
core/modules/comment/tests/src/Functional/CommentNonNodeTest.php +1 −3 Original line number Diff line number Diff line Loading @@ -277,8 +277,6 @@ public function testCommentFunctionality() { $this->assertSession()->statusCodeEquals(200); $this->assertSession()->fieldNotExists('edit-default-value-input-comment-und-0-status-0'); // Test that field to change cardinality is not available. $this->drupalGet('entity_test/structure/entity_test/fields/entity_test.entity_test.comment/storage'); $this->assertSession()->statusCodeEquals(200); $this->assertSession()->fieldNotExists('cardinality_number'); $this->assertSession()->fieldNotExists('cardinality'); Loading Loading @@ -439,7 +437,7 @@ public function testCommentFunctionality() { // Add a new comment field. $storage_edit = [ 'settings[comment_type]' => 'foobar', 'field_storage[subform][settings][comment_type]' => 'foobar', ]; $this->fieldUIAddNewField('entity_test/structure/entity_test', 'foobar', 'Foobar', 'comment', $storage_edit); Loading
core/modules/datetime/tests/src/Functional/DateTimeFieldTest.php +2 −2 Original line number Diff line number Diff line Loading @@ -932,8 +932,8 @@ public function testDateStorageSettings() { ]; $this->drupalGet('node/add/date_content'); $this->submitForm($edit, 'Save'); $this->drupalGet('admin/structure/types/manage/date_content/fields/node.date_content.' . $field_name . '/storage'); $this->assertSession()->elementsCount('xpath', "//*[@id='edit-settings-datetime-type' and contains(@disabled, 'disabled')]", 1); $this->drupalGet('admin/structure/types/manage/date_content/fields/node.date_content.' . $field_name); $this->assertSession()->elementsCount('xpath', "//*[@name='field_storage[subform][settings][datetime_type]' and contains(@disabled, 'disabled')]", 1); } }