public function commerce_add_to_cart_extras_handler_field_quantity::views_form_validate in Commerce Add to Cart Extras 7
File
- ./
commerce_add_to_cart_extras_handler_field_quantity.inc, line 128 - Views field handler. Adds the quantity field to the view. Implements the Views Form API.
Class
- commerce_add_to_cart_extras_handler_field_quantity
- Views field handler.
Code
public 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 ((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.'));
}
}
}