You are here

function eck__bundle__add_validate in Entity Construction Kit (ECK) 7

Same name and namespace in other branches
  1. 7.3 eck.bundle.inc \eck__bundle__add_validate()
  2. 7.2 eck.bundle.inc \eck__bundle__add_validate()

Validation for bundle creation (Make sure this bundle don't exist for thie entity type)

Parameters

$form: Form array provided by the Form API

$form_state: array provided by the Form API

1 string reference to 'eck__bundle__add_validate'
eck__bundle__add in ./eck.bundle.inc
ADD Entity types.

File

./eck.bundle.inc, line 195
All of the menu, pages, and forms related to bundle administration.

Code

function eck__bundle__add_validate($form, &$form_state) {
  $entity_type_name = $form_state['values']['entity_type_name'];

  // The type does not have to be unique in the table, but it should be unique
  // to its entity so we will check that here.
  foreach (eck__bundle__load($entity_type_name) as $bundle) {
    if ($bundle->name == $form_state['values']['bundle_name']) {
      form_set_error('bundle', t("bundle '{$bundle->name} already exists for this entity"));
    }
  }
}