Commit 37cf78d2 authored by catch's avatar catch

Issue #2555275 by dawehner: Fix missing schema for URI widget

parent 089e4f6b
...@@ -491,7 +491,7 @@ field.value.string_long: ...@@ -491,7 +491,7 @@ field.value.string_long:
# Schema for the configuration of the URI field type. # Schema for the configuration of the URI field type.
field.storage_settings.uri: field.storage_settings.uri:
type: mapping type: field.storage_settings.string
label: 'URI settings' label: 'URI settings'
mapping: mapping:
max_length: max_length:
......
...@@ -160,6 +160,17 @@ field.widget.settings.string_textarea: ...@@ -160,6 +160,17 @@ field.widget.settings.string_textarea:
type: label type: label
label: 'Placeholder' 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: field.widget.settings.email_default:
type: mapping type: mapping
label: 'Email field display format settings' label: 'Email field display format settings'
......
...@@ -32,9 +32,11 @@ class UriItem extends StringItem { ...@@ -32,9 +32,11 @@ class UriItem extends StringItem {
* {@inheritdoc} * {@inheritdoc}
*/ */
public static function defaultStorageSettings() { public static function defaultStorageSettings() {
return array( $storage_settings = parent::defaultStorageSettings();
'max_length' => 2048, // is_ascii doesn't make sense for URIs.
) + parent::defaultStorageSettings(); unset($storage_settings['is_ascii']);
$storage_settings['max_length'] = 2048;
return $storage_settings;
} }
/** /**
......
<?php
/**
* @file
* Contains \Drupal\field\Tests\Uri\UriItemTest.
*/
namespace Drupal\field\Tests\Uri;
use Drupal\Component\Utility\Unicode;
use Drupal\field\Entity\FieldConfig;
use Drupal\field\Entity\FieldStorageConfig;
use Drupal\field\Tests\FieldUnitTestBase;
/**
* Tests URI field functionality.
*
* @see \Drupal\Core\Field\Plugin\Field\FieldType\UriItem
*
* @group field
*/
class UriItemTest extends FieldUnitTestBase {
/**
* A field to use in this test class.
*
* @var \Drupal\field\Entity\FieldStorageConfig
*/
protected $fieldStorage;
/**
* The field used in this test class.
*
* @var \Drupal\field\Entity\FieldConfig
*/
protected $field;
/**
* 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();
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment