Skip to content

Instantly share code, notes, and snippets.

@nrackleff
Last active December 18, 2015 19:04
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save nrackleff/30a173619b98a664931c to your computer and use it in GitHub Desktop.
Save nrackleff/30a173619b98a664931c 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