You are here

function flexiform_manage_form_entities_form_validate in Flexiform 7

Validate the manage entities form

File

./flexiform.admin.inc, line 1541
Model type editing UI.

Code

function flexiform_manage_form_entities_form_validate($form, &$form_state) {
  $entity = $form_state['values']['entities']['_add_entity'];
  if (array_filter(array(
    $entity['label'],
    $entity['namespace'],
    $entity['entity_type'],
    $entity['bundle'],
    $entity['getter'],
  ))) {

    // Missing Label
    if (!$entity['label']) {
      form_set_error('entities][_add_entity][label', t('Add entity: you must provide a label'));
    }
    if (!$entity['namespace']) {

      // @todo: Check this is unique and machine nameable
      form_set_error('entities][_add_entity][namespace', t('Add entity: you must choose a unique namespace'));
    }
    if (!$entity['entity_type']) {
      form_set_error('entities][_add_entity][entity_type', t('Add entity: you must choose an entity type'));
    }
    if (!$entity['bundle']) {
      form_set_error('entities][_add_entity][bundle', t('Add entity: you must choose a bundle'));
    }
    if (!$entity['getter']) {
      form_set_error('entities][_add_entity][getter', t('Add entity: you must choose an entity getter callback'));
    }
  }
}