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/modules/field/src/Tests/Uri/UriFieldTest.php b/core/modules/field/src/Tests/Uri/UriFieldTest.php new file mode 100644 index 0000000..61fd8f3 --- /dev/null +++ b/core/modules/field/src/Tests/Uri/UriFieldTest.php @@ -0,0 +1,103 @@ +drupalLogin($this->drupalCreateUser([ + 'view test entity', + 'administer entity_test content', + 'administer entity_test form display', + 'administer entity_test fields', + ])); + } + + /** + * Tests URI field. + */ + public function testUriField() { + $label = $this->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(); + + // Create a display for the full view mode. + entity_get_display('entity_test', 'entity_test', 'full') + ->setComponent($field_name, [ + 'type' => 'uri_link', + ]) + ->save(); + } + +}