function hook_mathfield_get_token_value_MODULE_alter in Math Field 7
Alter the value of a field token of a module for use in a math expression.
This hook allows other modules to change the replacement value of a token for a field type defined in the module MODULE.
Parameters
int|float|bool $value: The current numeric value of the field or FALSE.
array $context: An associative array with the following keys:
- 'field_name': The machine name of the token field.
- 'delta': The delta value of the token field for multivalue fields. Default is 0.
- 'column': The source column of the token field. Default is 'value'.
- 'token': The token used in the math expression.
- 'field': The field definition of the token field.
- 'instance': The field instance definition of the token field.
- 'element': The mathfield form element.
- 'form_state' The entire form_state array including submitted values. The token value is usually extracted from $context['form_state']['values'].
2 functions implement hook_mathfield_get_token_value_MODULE_alter()
Note: this list is generated by pattern matching, so it may include some functions that are not actually implementations of this hook.
- mathfield_mathfield_get_token_value_list_alter in ./
mathfield.module - Implements hook_mathfield_get_token_value_MODULE_alter() for the list.module.
- mathfield_mathfield_get_token_value_number_alter in ./
mathfield.module - Implements hook_mathfield_get_token_value_MODULE_alter() for the number.module.
File
- ./
mathfield.api.php, line 231 - Hooks provided by Math Field.
Code
function hook_mathfield_get_token_value_MODULE_alter(&$value, $context) {
$values = $context['form_state']['values'];
$field_name = $context['field_name'];
$language = $context['element']['#language'];
$delta = $context['delta'];
$column = $context['column'];
if (isset($values[$field_name][$language][$delta][$column]) && is_numeric($values[$field_name][$language][$delta][$column])) {
$value = $values[$field_name][$language][$delta][$column];
}
}