I'm in the need for a extra validation on an existing drupal commerce form (commerce_cart_add_to_cart_form_##), strangely the validation function is not called on the first form submit, but on the 2nd submit and all the submits after the 2nd. There are multiple commerce_cart_add_to_cart_forms on a single page.
Here's my module code:
function val_form_alter(&$form, &$form_state, $form_id) {
if (strpos($form_id, 'commerce_cart_add_to_cart_form_') !== false) {
$form['#validate'][] = 'val_commerce_cart_add_to_cart_form_validate';
}
}
function val_commerce_cart_add_to_cart_form_validate($form, &$form_state) {
dpm('validating function called');
form_set_error('quantity', t("ERROR"));
}
Any Ideas? And, as a second question: there are different $from_ids (commerce_cart_add_to_cart_form_##) that will all need the same validation. Is there a way to call them all other than I did?
Thanks!