Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Problem/Motivation
If an form element of '#type' => 'color'
receives an empty value it falls back to black:
// Default to black if no value is given.
// @see http://www.w3.org/TR/html5/number-state.html#color-state
if ($value === '') {
$form_state->setValueForElement($element, '#000000');
}
- \Drupal\Core\Render\Element\Color::validateColor()
(No need to follow that link, by the way, it's a 404. :-/)
That means it's not possible to use the color input for an input element. For example the Rotate image effect has a configurable Background color, but that is optional, to allow for transparent images. That cannot use '#type' => 'color'
due to this problem.
Proposed resolution
?
Comments
Comment #2
mgoncalves CreditAttribution: mgoncalves at CI&T commentedWorking on it.
Comment #3
mgoncalves CreditAttribution: mgoncalves at CI&T commentedHello @tstoeckler,
According with documentation of W3 Color Type, the value attribute, must have a value.
Could you provide more information about the issue ?
Thanks you.
Comment #4
mgoncalves CreditAttribution: mgoncalves at CI&T commentedComment #16
DanielVezaThanks for opening an issue!
Color was removed from Drupal 10 and this has had no activity in 6 years. Marking as closed.
Comment #17
dpiThe color render element is still in core.