function mathfield_form_set_value in Math Field 7
Helper to set a mathfield form element value.
Parameters
array $element: A mathfield form element.
mixed $value: The computed value for the mathfield.
array $form_state: The form_state array.
2 calls to mathfield_form_set_value()
- mathfield_form_afterbuild in ./
mathfield.module - Afterbuild callbcak for forms with math expression fields.
- _mathfield_evaluate_element in ./
mathfield.module - Helper to evaluate a single mathfield element.
File
- ./
mathfield.module, line 391 - Adds a dynamic math expression field.
Code
function mathfield_form_set_value($element, $value, &$form_state) {
if ($element['#widget'] == 'mathfield_markup') {
// For readonly math expressions, the event is triggered on the display
// textfield but we only want to save the 'value' column. We use
// array_splice() to change the column from 'display' to 'value'.
array_splice($element['#parents'], -1, 1, array(
'value',
));
}
form_set_value($element, $value, $form_state);
}