function _mathfield_evaluate_element in Math Field 7
Helper to evaluate a single mathfield element.
Parameters
array $element: The mathfield element definition.
array $form_state: The current form state including submitted values.
1 call to _mathfield_evaluate_element()
- mathfield_widget_validate in ./
mathfield.module - Validate callback to evaluate the math expression.
File
- ./
mathfield.module, line 368 - Adds a dynamic math expression field.
Code
function _mathfield_evaluate_element($element, &$form_state) {
$expression = $element['#settings']['expression'];
$replacements = mathfield_get_token_values($element, $form_state);
$value = mathfield_evaluate($expression, $element['#settings'], $replacements);
if ($value !== FALSE) {
mathfield_form_set_value($element, $value, $form_state);
}
else {
// Could not evaluate the field.
mathfield_form_set_value($element, '', $form_state);
}
}