You are here

function nice_mega_dropdowns_menu_edit_item_submit in Nice Menus 7.2

Same name and namespace in other branches
  1. 7.3 nice_mega_dropdowns/nice_mega_dropdowns.module \nice_mega_dropdowns_menu_edit_item_submit()
1 string reference to 'nice_mega_dropdowns_menu_edit_item_submit'
nice_mega_dropdowns_form_menu_edit_item_alter in nice_mega_dropdowns/nice_mega_dropdowns.module
Implements hook_form_FORM_ID_alter().

File

nice_mega_dropdowns/nice_mega_dropdowns.module, line 63
Module which allows nodes to be used as dropdown menus.

Code

function nice_mega_dropdowns_menu_edit_item_submit(&$form, &$form_state) {
  $dropdowns = variable_get('nice_mega_dropdowns', 0);
  if (!$dropdowns) {
    $dropdowns = array();
  }
  if ($form_state['values']['dropdown']) {
    $query = new EntityFieldQuery();
    $result = $query
      ->entityCondition('entity_type', 'node')
      ->propertyCondition('title', $form_state['values']['dropdown'])
      ->execute();
    $dropdowns[$form_state['values']['mlid']] = array_pop($result['node'])->nid;
    variable_set('nice_mega_dropdowns', $dropdowns);
  }
  else {
    unset($dropdowns[$form_state['values']['mlid']]);
    variable_set('nice_mega_dropdowns', $dropdowns);
  }
}