You are here

function event_calendar_form_taxonomy_form_vocabulary_alter in Event Calendar 7

Implements hook_form_FORM_ID_alter().

Set access FALSE for not to delete module defined vocabulary. Make vocabulary name 'readonly'.

File

./event_calendar.module, line 273
The module file that allows events to be created and required admin approval.

Code

function event_calendar_form_taxonomy_form_vocabulary_alter(&$form, &$form_state, $form_id) {

  // Build query to fetch available terms.
  $vid = db_query("SELECT vid FROM {taxonomy_vocabulary} WHERE machine_name = :machine_name", array(
    ':machine_name' => TAXONOMY_NAME,
  ))
    ->fetchField();

  // Disable access to delete and set readonly.
  if (isset($form['#vocabulary']->vid) && $form['#vocabulary']->vid == $vid) {
    $form['machine_name']['#attributes']['readonly'] = 'readonly';
    $form['actions']['delete']['#access'] = FALSE;
  }
}