function hook_mathfield_get_token in Math Field 7
Get the jQuery selector and event to trigger the evaluation of a mathfield.
This hook is invoked on the module that defines the tokens' field type. To change the token info for a field defined in a different module, use hook_mathfield_get_token_alter() or hook_mathfield_get_token_MODULE_alter().
Parameters
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.
Return value
array An associative 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.
1 function implements hook_mathfield_get_token()
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 in ./
mathfield.module - Implements hook_mathfield_get_token().
1 invocation of hook_mathfield_get_token()
- mathfield_get_tokens in ./
mathfield.module - Get the element details for mathfield expression tokens.
File
- ./
mathfield.api.php, line 34 - Hooks provided by Math Field.
Code
function hook_mathfield_get_token($context) {
$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'],
)),
));
return array(
'selector' => 'input[name="' . $name . '"]',
'event' => 'blur',
);
}