function color_palette_color_value
Same name in other branches
- 9 core/modules/color/color.module \color_palette_color_value()
- 8.9.x core/modules/color/color.module \color_palette_color_value()
Determines the value for a palette color field.
Parameters
$element: The form element whose value is being populated.
$input: The incoming input to populate the form element. If this is FALSE, the element's default value should be returned.
$form_state: A keyed array containing the current state of the form.
Return value
The data that will appear in the $form_state['values'] collection for this element. Return nothing to use the default.
1 string reference to 'color_palette_color_value'
- color_scheme_form in modules/
color/ color.module - Form constructor for the color configuration form for a particular theme.
File
-
modules/
color/ color.module, line 313
Code
function color_palette_color_value($element, $input = FALSE, $form_state = array()) {
// If we suspect a possible cross-site request forgery attack, only accept
// hexadecimal CSS color strings from user input, to avoid problems when this
// value is used in the JavaScript preview.
if ($input !== FALSE) {
// Start with the provided value for this textfield, and validate that if
// necessary, falling back on the default value.
$value = form_type_textfield_value($element, $input, $form_state);
if (!$value || !isset($form_state['complete form']['#token']) || color_valid_hexadecimal_string($value) || drupal_valid_token($form_state['values']['form_token'], $form_state['complete form']['#token'])) {
return $value;
}
else {
return $element['#default_value'];
}
}
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.