function hook_mathfield_get_token_MODULE_alter in Math Field 7
Alter the jQuery selector and event for triggering a mathfield for a module.
This hook allows other modules to change the jQuery selector or event for a field type defined in the module MODULE.
Parameters
array $data: The current token data. An assoicative array with the following keys:
- 'selector': The jQuery selector for the form element that will tirgger the mathfield evaluation.
- 'event': The jQuery event that will trigger the mathfield evaluation. Typically, blur of text input and change for select lists and radios/checkboxes.
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.
4 functions implement hook_mathfield_get_token_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_list_alter in ./
mathfield.module - Implements hook_mathfield_get_token_MODULE_alter() for the list.module.
- mathfield_mathfield_get_token_number_alter in ./
mathfield.module - Implements hook_mathfield_get_token_MODULE_alter() for the number.module.
- 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 117 - Hooks provided by Math Field.
Code
function hook_mathfield_get_token_MODULE_alter(&$data, $context) {
if (empty($data)) {
$field_name = $context['field']['field_name'];
$name = strtr('@field_name[@parts]', array(
'@field_name' => $field_name,
'@parts' => implode('][', array(
$context['element']['#language'],
$context['delta'],
$context['column'],
)),
));
$data = array(
'selector' => 'input[name="' . $name . '"]',
'event' => 'blur',
);
}
}