Error: Argument 2 passed to drupal_array_get_nested_value() must be of the type array, string given
The error:


  Argument 2 passed to drupal_array_get_nested_value() must be an array, string or null given


means there is a problem with the structure of your form you're trying to submit. So string/NULL were given instead of array for the second parameter.

The function:

&amp;drupal_array_get_nested_value(array &amp;$array, array $parents, &amp;$key_exists = NULL)


retrieves a value from a nested array with variable depth, for example:

$value = drupal_array_get_nested_value($form, $parents);


Here are the example calls from Drupal core (see the 2nd argument):

./common.inc:  drupal_array_get_nested_value($array, $parents, $key_exists);
./form.inc:      $input = drupal_array_get_nested_value($form_state['input'], $element['#parents'], $input_exists);
./form.inc:  $source = drupal_array_get_nested_value($form_state['complete form'], $element['#machine_name']['source'], $key_exists);


If you don't know which field is causing it, the easiest way to find out is by doing this simple hack (which should be reverted after that of course):

function &amp;drupal_array_get_nested_value(array &amp;$array, $parents, &amp;$key_exists = NULL) {
  if (!is_array($parents)) { var_dump($parents, debug_backtrace()); exit; }


Which would display value of $parents which should be an array and the backtrace.

Usually this could happen during the validation and it can caused by invalid #parents or #limit_validation_errors structure of form array.

If there is no any custom coding involved, then it's a bug of the contrib module which cause that (e.g. Conditional Fields, Email Field, Entity Translation, etc.), so it should be reported against the right module.



In my specific case, I've to fix #limit_validation_errors by wrapping it into array() where it contained list of $group['children']:

  $form['actions']['continue'] = array(
    '#type' =&gt; 'submit',
    '#value' =&gt; t('Continue'),
    '#limit_validation_errors' =&gt; array($validate_fields),
    '#submit' =&gt; array('foo_form_submit'),
    '#validate' =&gt; array('foo_form_validate'),
  );