function mathfield_widget_validate in Math Field 7
Validate callback to evaluate the math expression.
1 string reference to 'mathfield_widget_validate'
- mathfield_field_widget_form in ./
mathfield.module - Implements hook_field_widget_form().
File
- ./
mathfield.module, line 339 - Adds a dynamic math expression field.
Code
function mathfield_widget_validate($form, &$form_state) {
$submitted = $form_state['submitted'];
$trigger = $form_state['triggering_element'];
// Evaluate all empty mathfield elements on form submission otherwise only
// evaluate the triggered mathfield. We cannot evaluate expressions in
// an #element_validate handler because all dependent fields may not be
// available yet.
if ($submitted && !empty($form_state['mathfield'])) {
foreach ($form_state['mathfield'] as $element) {
$submitted_value = drupal_array_get_nested_value($form_state['values'], $element['#parents']);
if (empty($submitted_value) || $element['#widget'] == 'mathfield_markup') {
_mathfield_evaluate_element($element, $form_state);
}
}
}
elseif (isset($trigger['#settings']['expression'])) {
_mathfield_evaluate_element($trigger, $form_state);
}
}