diff --git a/core/config/schema/core.data_types.schema.yml b/core/config/schema/core.data_types.schema.yml index 79e3f14..3d4f3a0 100644 --- a/core/config/schema/core.data_types.schema.yml +++ b/core/config/schema/core.data_types.schema.yml @@ -491,7 +491,7 @@ field.value.string_long: # Schema for the configuration of the URI field type. field.storage_settings.uri: - type: mapping + type: field.storage_settings.string label: 'URI settings' mapping: max_length: diff --git a/core/config/schema/core.entity.schema.yml b/core/config/schema/core.entity.schema.yml index cc1a57e..71b7ccd 100644 --- a/core/config/schema/core.entity.schema.yml +++ b/core/config/schema/core.entity.schema.yml @@ -160,6 +160,17 @@ field.widget.settings.string_textarea: type: label label: 'Placeholder' +field.widget.settings.uri: + type: mapping + label: 'URI field' + mapping: + size: + type: integer + label: 'Size of URI field' + placeholder: + type: label + label: 'Placeholder' + field.widget.settings.email_default: type: mapping label: 'Email field display format settings' diff --git a/core/lib/Drupal/Core/Field/Plugin/Field/FieldType/UriItem.php b/core/lib/Drupal/Core/Field/Plugin/Field/FieldType/UriItem.php index 3f7805b..1481d88 100644 --- a/core/lib/Drupal/Core/Field/Plugin/Field/FieldType/UriItem.php +++ b/core/lib/Drupal/Core/Field/Plugin/Field/FieldType/UriItem.php @@ -32,9 +32,11 @@ class UriItem extends StringItem { * {@inheritdoc} */ public static function defaultStorageSettings() { - return array( - 'max_length' => 2048, - ) + parent::defaultStorageSettings(); + $storage_settings = parent::defaultStorageSettings(); + // is_ascii doesn't make sense for URIs. + unset($storage_settings['is_ascii']); + $storage_settings['max_length'] = 2048; + return $storage_settings; } /** diff --git a/core/modules/field/src/Tests/Uri/UriItemTest.php b/core/modules/field/src/Tests/Uri/UriItemTest.php new file mode 100644 index 0000000..46ffe0a --- /dev/null +++ b/core/modules/field/src/Tests/Uri/UriItemTest.php @@ -0,0 +1,73 @@ +randomMachineName(); + + // Create a field with settings to validate. + $field_name = Unicode::strtolower($this->randomMachineName()); + $this->fieldStorage = FieldStorageConfig::create([ + 'field_name' => $field_name, + 'entity_type' => 'entity_test', + 'type' => 'uri', + ]); + $this->fieldStorage->save(); + $this->field = FieldConfig::create([ + 'field_name' => $field_name, + 'entity_type' => 'entity_test', + 'bundle' => 'entity_test', + 'label' => $label, + 'required' => TRUE, + 'settings' => [ + 'size' => 123, + 'placeholder' => '', + ], + ]); + $this->field->save(); + + // Create a form display for the default form mode. + entity_get_form_display('entity_test', 'entity_test', 'default') + ->setComponent($field_name, [ + 'type' => 'uri', + ]) + ->save(); + } + +}