function mathfield_mathfield_get_token_list_alter in Math Field 7
Implements hook_mathfield_get_token_MODULE_alter() for the list.module.
Related topics
File
- ./
mathfield.module, line 720 - Adds a dynamic math expression field.
Code
function mathfield_mathfield_get_token_list_alter(&$data, $context) {
if (empty($data)) {
if (in_array($context['field']['type'], array(
'list_integer',
'list_float',
))) {
// @TODO: Support multivalue fields.
if ($context['field']['cardinality'] != 1 || $context['delta'] > 0) {
$data = array();
return;
}
$name = strtr('@field_name[@parts]', array(
'@field_name' => $context['field_name'],
'@parts' => $context['element']['#language'],
));
// Support default options elements.
switch ($context['instance']['widget']['type']) {
case 'options_buttons':
$data = array(
'selector' => 'input[name="' . $name . '"]',
'event' => 'change',
);
break;
case 'options_select':
$data = array(
'selector' => 'select[name="' . $name . '"]',
'event' => 'change',
);
break;
}
}
}
}