You are here

function mandrill_activity_entity_form_validate in Mandrill 7

Same name and namespace in other branches
  1. 7.2 modules/mandrill_activity/mandrill_activity.admin.inc \mandrill_activity_entity_form_validate()

Validation callback for mandrill_activity_entity_form().

File

modules/mandrill_activity/mandrill_activity.admin.inc, line 144
Administration pages for mandrill_activity module.

Code

function mandrill_activity_entity_form_validate($form, &$form_state) {
  $extant_mc_entities = entity_load('mandrill_activity_entity');
  $form_id = $form_state['mandrill_activity_entity']->mandrill_activity_entity_id;
  $form_bundle = $form_state['values']['bundle'];
  $form_entity_id = $form_state['values']['entity_type'];
  foreach ($extant_mc_entities as $extant_ent) {
    if ($form_bundle == $extant_ent->bundle && $form_entity_id == $extant_ent->entity_type && $form_id != $extant_ent->mandrill_activity_entity_id) {
      form_set_error('bundle', t('A Mandrill Activity Entity already exists for this Bundle. Either select a different Bundle or edit the !link for this bundle.', array(
        '!link' => l(t('existing Mandrill Activity Entity'), "admin/config/services/mandrill/activity/manage/{$extant_ent->name}"),
      )));
    }
  }
}