I installed a clean drupal 7.15, added a menu in the "Main Menu" and the subtitle field doesn't get saved at all.

Comments

Methos76’s picture

Component: Miscellaneous » Code
Assigned: Unassigned » Methos76

You are right. I tried this module too, 'cause I need subtitles for a project, and had the same problem.
But I'm a coder, so i looked into the module code and fixed the problem. There seemed to be code missing for inserting new entries into the database.
so I changed this code:

function menu_subtitle_form_submit($form, &$form_state) {
  $subtitle = ($form_state['values']['menu_subtitle'] ? $form_state['values']['menu_subtitle'] : '');

  db_update('menu_subtitle')->fields(array(
    'subtitle' => $subtitle,
  ))->condition('mlid', $form_state['values']['mlid'])->execute();
}

to this:

function menu_subtitle_form_submit($form, &$form_state) {
  $entryexists = false;  
  $subtitle = ($form_state['values']['menu_subtitle'] ? $form_state['values']['menu_subtitle'] : '');

  $result = db_query('SELECT * FROM {menu_subtitle} WHERE mlid = :mlid',array(':mlid'=>$form_state['values']['mlid']));
  if ($result)
  {
    foreach ($result as $record)
    {
      if ($record->mlid == $form_state['values']['mlid'])
        $entryexists = true;
    }    
  }
 
  if ($entryexists)
    db_update('menu_subtitle')->fields(array(
      'subtitle' => $subtitle,
    ))->condition('mlid', $form_state['values']['mlid'])->execute();
  else
    db_insert('menu_subtitle')->fields( array('mlid' => $form_state['values']['mlid'],
                                              'subtitle' => $subtitle))->execute();
}

Now new entries are saved and existing entries are updated.
Would be glad if this helps someone and could be put into a new release.

mecmartini’s picture

Status: Active » Fixed

You were right!

It's because in the alpha1 I changed the way to store the data and I forgot to update the menu_subtitle_form_submit() function.

I fixed it and a new release is coming!

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

Anonymous’s picture

Issue summary: View changes

added to the Main Menu