1 color.module | color_palette_color_value($element, $input = FALSE, $form_state = array()) |
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.
File
- core/
modules/ color/ color.module, line 441 - Allows users to change the color scheme of themes.
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) || backdrop_valid_token($form_state['values']['form_token'], $form_state['complete form']['#token'])) {
return $value;
}
else {
return $element['#default_value'];
}
}
}