function commerce_line_item_handler_field_edit_quantity::views_form_validate in Commerce Core 7
File
- modules/
line_item/ includes/ views/ handlers/ commerce_line_item_handler_field_edit_quantity.inc, line 68 - Field handler to present a form field to change quantity of a line item. It's a dummy handler, most part of the implementation is done via post render hook.
Class
- commerce_line_item_handler_field_edit_quantity
- Field handler to present a field to change quantity of a line item.
Code
function views_form_validate($form, &$form_state) {
$field_name = $this->options['id'];
foreach (element_children($form[$field_name]) as $row_id) {
// Ensure the quantity is actually a numeric value.
if (!is_numeric($form_state['values'][$field_name][$row_id]) || $form_state['values'][$field_name][$row_id] < 0) {
form_set_error($field_name . '][' . $row_id, t('You must specify a positive number for the quantity'));
}
// If the custom data type attribute of the quantity element is integer,
// ensure we only accept whole number values.
if ($form[$field_name][$row_id]['#datatype'] == 'integer' && (int) $form_state['values'][$field_name][$row_id] != $form_state['values'][$field_name][$row_id]) {
form_set_error($field_name . '][' . $row_id, t('You must specify a whole number for the quantity.'));
}
}
}