Early Bird Registration for DrupalCon Portland 2024 is open! Register by 23:59 PST on 31 March 2024, to get $100 off your ticket.
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
Comment #1
Christopher Riley CreditAttribution: Christopher Riley commentedSo is there no way to add an additional validation function to a form in the admin add/edit screen?
Comment #2
bojanz CreditAttribution: bojanz commentedhook_field_attach_form_validate()?
hook_inline_entity_form_entity_form_alter() that adds #element_validate callbacks?
Comment #3
edutrul CreditAttribution: edutrul commentedHi 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'.
Comment #4
bojanz CreditAttribution: bojanz commented