Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Greg-Boggs/03017355e5d94e41e840 to your computer and use it in GitHub Desktop.
Save Greg-Boggs/03017355e5d94e41e840 to your computer and use it in GitHub Desktop.
<?php
// Inside form alter function insert validation using buttons like commerce does.
// Insert the validation at the beginning of the array so the commerce module
// can access any of our errors and place them in the correct block instead of at top of page.
array_unshift($form['buttons']['continue']['#validate'], 'treepeople_commerce2_organization_validate');
// Inside the validate function, set the errors using a special concatenated field name
// that include the panel the field is in. Notice there are no outer brackets.
form_set_error('customer_profile_billing][field_organization_name', t('Company/Organization Name field is required.'));
The commerce validation function will use that naming convention to place the error is the proper location on the page.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment