You are here

function eck__bundle__add_validate in Entity Construction Kit (ECK) 7.3

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

Bundle add form validation callback.

1 string reference to 'eck__bundle__add_validate'
eck__bundle__add in ./eck.bundle.inc
Bundle add from callback.

File

./eck.bundle.inc, line 273

Code

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

  // 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 (Bundle::loadByEntityType($entity_type) as $bundle) {
    if ($bundle->name == $form_state['values']['bundle_name']) {
      form_set_error('bundle', t("bundle @bundle_name already exists for this entity type", array(
        "@bundle_name" => $bundle->name,
      )));
    }
  }
}