Same name and namespace in other branches
- 3.0.x src/Plugin/Field/FieldType/ColorFieldType.php \Drupal\color_field\Plugin\Field\FieldType\ColorFieldType::generateSampleValue()
Fichier
-
src/
Plugin/ Field/ FieldType/ ColorFieldType.php, line 190
Classe
- ColorFieldType
- Plugin implementation of the 'color_type' field type.
Namespace
Drupal\color_field\Plugin\Field\FieldTypeCode
public static function generateSampleValue(FieldDefinitionInterface $field_definition) {
$settings = $field_definition->getSettings();
if ($format = $settings['format']) {
switch ($format) {
case '#HEXHEX':
$values['color'] = '#111AAA';
break;
case 'HEXHEX':
$values['color'] = '111111';
break;
case '#hexhex':
$values['color'] = '#111aaa';
break;
case 'hexhex':
$values['color'] = '111111';
break;
}
}
$values['opacity'] = 1;
return $values;
}