You are here

function organigrams_form_organigrams_validate in Organigrams 7

Form validation handler for 'organigrams_form_organigrams'.

File

./organigrams.admin.inc, line 449
Defines the administration forms for managing organigrams.

Code

function organigrams_form_organigrams_validate($form, &$form_state) {

  // During the deletion there is no 'machine_name' key.
  if (isset($form_state['values']['machine_name'])) {

    // Do not allow machine names to conflict with organigrams path arguments.
    $machine_name = $form_state['values']['machine_name'];

    // Invalid machine names which will conflict with the organigrams path
    // arguments.
    $disallowed = array(
      'add',
      'list',
    );

    // Check if the machine name has on of the disallowed values.
    if (in_array($machine_name, $disallowed)) {

      // Raise form error.
      form_set_error('machine_name', t('The machine-readable name cannot be "add" or "list".'));
    }
  }

  // Allow the entity fields to be validated.
  entity_form_field_validate('organigrams', $form, $form_state);
}