I am using the multiple values option within my admin add/edit order screen on custom line items. Can someone give me a suggestion as to how to easily slide in an additional form validation as I have custom fields that I need to do specialized validation on to populate hidden line item fields. I looked at the api as well as the commerce line item include file of Inline Entity and although I am sure I am just overlooking the obvious.

Thanks in advance.

Comments

So is there no way to add an additional validation function to a form in the admin add/edit screen?

hook_field_attach_form_validate()?
hook_inline_entity_form_entity_form_alter() that adds #element_validate callbacks?

Hi cmriley,

use what bojanz said Or maybe use form_alter and add a custom validation

$form['#validate'][] = 'module_grupo_node_form_form_validate';

and start debugging with dpm(), print_r(), etc just like any other form to look for the fields

to use form_set_error for each field check array #parents...

check https://api.drupal.org/api/drupal/includes%21form.inc/function/form_set_...

$name: The name of the form element. If the #parents property of your form element is array('foo', 'bar', 'baz') then you may set an error on 'foo' or 'foo][bar][baz'. Setting an error on 'foo' sets an error for every element where the #parents array starts with 'foo'.

Issue summary:View changes
Status:Active» Fixed

Status:Fixed» Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.