diff --git a/core/modules/options/lib/Drupal/options/Plugin/Field/FieldType/ListItemBase.php b/core/modules/options/lib/Drupal/options/Plugin/Field/FieldType/ListItemBase.php index 5b9e8fb..f78589a 100644 --- a/core/modules/options/lib/Drupal/options/Plugin/Field/FieldType/ListItemBase.php +++ b/core/modules/options/lib/Drupal/options/Plugin/Field/FieldType/ListItemBase.php @@ -228,16 +228,17 @@ public function validateAllowedValues($element, &$form_state) { * * @param string $string * The list of allowed values in string format described in - * options_allowed_values_string(). + * allowedValuesString(). * @param bool $generate_keys - * Boolean value indicating whether to generate keys based on the position of - * the value if a key is not manually specified, and if the value cannot be - * used as a key. This should only be TRUE for fields of type 'list_number'. + * Boolean value indicating whether to generate keys based on the position + * of the value if a key is not manually specified, and if the value cannot + * be used as a key. This should only be TRUE for fields of type + * 'list_number'. * * @return array * The array of extracted key/value pairs, or NULL if the string is invalid. * - * @see options_allowed_values_string() + * @see allowedValuesString() */ protected function extractAllowedValues($string, $generate_keys) { // @todo Move type-specific logic to the type-specific subclass: diff --git a/core/modules/options/lib/Drupal/options/Plugin/Field/FieldType/ListTextItem.php b/core/modules/options/lib/Drupal/options/Plugin/Field/FieldType/ListTextItem.php index 939fd7e..1e27eac 100644 --- a/core/modules/options/lib/Drupal/options/Plugin/Field/FieldType/ListTextItem.php +++ b/core/modules/options/lib/Drupal/options/Plugin/Field/FieldType/ListTextItem.php @@ -55,28 +55,11 @@ public static function schema(FieldDefinitionInterface $field_definition) { */ public function getPropertyDefinitions() { if (!isset(static::$propertyDefinitions)) { + $constraints = array('Length' => array('max' => 255)); static::$propertyDefinitions['value'] = DataDefinition::create('string') - ->setLabel(t('Text value')); + ->setLabel(t('Text value')) + ->setConstraints($constraints); } return static::$propertyDefinitions; } - - /** - * {@inheritdoc} - */ - public function getConstraints() { - $constraint_manager = \Drupal::typedDataManager()->getValidationConstraintManager(); - $constraints = parent::getConstraints(); - - $constraints[] = $constraint_manager->create('ComplexData', array( - 'value' => array( - 'Length' => array( - 'max' => 255, - ), - ), - )); - - return $constraints; - } - }