diff --git a/core/modules/field/field.module b/core/modules/field/field.module index 681fc63..81b6ae6 100644 --- a/core/modules/field/field.module +++ b/core/modules/field/field.module @@ -263,14 +263,6 @@ function _field_generate_entity_field_definition(FieldInterface $field, FieldIns } /** - * Implements hook_field_widget_info_alter(). - */ -function field_field_widget_info_alter(&$info) { - // Add the Hidden widget to all field types. - $info['hidden']['field_types'] = array_keys(\Drupal::service('plugin.manager.entity.field.field_type')->getDefinitions()); -} - -/** * Implements hook_entity_bundle_create(). */ function field_entity_bundle_create($entity_type, $bundle) { diff --git a/core/modules/field/lib/Drupal/field/Plugin/field/widget/HiddenWidget.php b/core/modules/field/lib/Drupal/field/Plugin/field/widget/HiddenWidget.php deleted file mode 100644 index 33d7b76..0000000 --- a/core/modules/field/lib/Drupal/field/Plugin/field/widget/HiddenWidget.php +++ /dev/null @@ -1,34 +0,0 @@ -field_single; $field['entity_type'] = $entity_type; @@ -591,18 +592,15 @@ function testFieldFormHiddenWidget() { entity_create('field_entity', $field)->save(); $this->instance = entity_create('field_instance', $this->instance); $this->instance->save(); - entity_get_form_display($this->instance['entity_type'], $this->instance['bundle'], 'default') - ->setComponent($this->instance['field_name'], array( - 'type' => 'hidden', - )) - ->save(); + // We explicitly do not assign a widget in the form display, so the field + // stays hidden in forms. // Display the entity creation form. $this->drupalGet($entity_type . '/add'); // Create an entity and test that the default value is assigned correctly to // the field that uses the hidden widget. - $this->assertNoField("{$field_name}[0][value]", 'The hidden widget is not displayed'); + $this->assertNoField("{$field_name}[$langcode][0][value]", 'The field does not appear in the form'); $this->drupalPostForm(NULL, array('user_id' => 1, 'name' => $this->randomName()), t('Save')); preg_match('|' . $entity_type . '/manage/(\d+)/edit|', $this->url, $match); $id = $match[1]; @@ -615,9 +613,7 @@ function testFieldFormHiddenWidget() { $this->instance['default_value'] = NULL; $this->instance->save(); entity_get_form_display($this->instance['entity_type'], $this->instance['bundle'], 'default') - ->setComponent($this->instance['field_name'], array( - 'type' => 'test_field_widget', - )) + ->removeComponent($this->instance['field_name']) ->save(); // Display edit form. @@ -635,9 +631,7 @@ function testFieldFormHiddenWidget() { // Update the form display and switch to the Hidden widget again. entity_get_form_display($this->instance['entity_type'], $this->instance['bundle'], 'default') - ->setComponent($this->instance['field_name'], array( - 'type' => 'hidden', - )) + ->removeComponent($this->instance['field_name']) ->save(); // Create a new revision. diff --git a/core/modules/field_ui/lib/Drupal/field_ui/FormDisplayOverview.php b/core/modules/field_ui/lib/Drupal/field_ui/FormDisplayOverview.php index 1186fc2..70b63f5 100644 --- a/core/modules/field_ui/lib/Drupal/field_ui/FormDisplayOverview.php +++ b/core/modules/field_ui/lib/Drupal/field_ui/FormDisplayOverview.php @@ -85,6 +85,13 @@ protected function getPlugin($instance, $configuration) { /** * {@inheritdoc} */ + protected function getPluginOptions($field_type) { + return parent::getPluginOptions($field_type) + array('hidden' => '- ' . t('Hidden') . ' -'); + } + + /** + * {@inheritdoc} + */ protected function getDefaultPlugin($field_type) { return $this->fieldTypes[$field_type]['default_widget']; }