I get the above error after a creating a new content type.

Warning: explode() expects parameter 2 to be string, array given in menu_node_submit()

The function which gives error is shown below :

function menu_node_submit($node, $form, $form_state) {
  // Decompose the selected menu parent option into 'menu_name' and 'plid', if
  // the form used the default parent selection widget.
  if (!empty($form_state['values']['menu']['parent'])) {
    list($node->menu['menu_name'], $node->menu['plid']) = explode(':', $form_state['values']['menu']['parent']);

 * Implements hook_form_FORM_ID_alter().
 * Adds menu options to the node type form.

The line that is throwing the error is in the core menu.module. The arguments that are getting passed to it are not valid. To troubleshoot it you would have to backtrace what is getting passed to it to see what is malforming the data or not creating proper data in the first place. If you use debug_backtrace you should be able to find where the bad data is originating from.

Specifically $form_state['values']['menu']['parent'] should be a string (to have explode work on it) but at that time, it is an array.

| improve this answer | |

This is because you tired to explode array. See explode().

 $arrayString =   explode(",",$string);

You can't explode array. It is already a collection of elements.

| improve this answer | |
  • 1
    $arrayString = explode(",",$string); what does this line mean? where should the changes be done? The function above is inside a module Pls.. tell me where & what should I change? – harshal Feb 11 '13 at 10:19
  • well, find your explode function and replace your array variable name with string. I can say, unless you show me the code containing explode block. – Suresh KUMAR Mukhiya Feb 11 '13 at 10:20
  • i have not used explode() in my module ? – harshal Feb 11 '13 at 10:21
  • The error is showing in the menu module which is i guess inbuilt in drupal 7 – harshal Feb 11 '13 at 10:22
  • the error must have given line number and page. if it was created by you then probably your error. but logically the error indicates the used of explode function where array is passed as arguments. – Suresh KUMAR Mukhiya Feb 11 '13 at 10:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.