Error on installation, on the page "Congratulations, Drupal has been successfully installed.":

notice: Array to string conversion in includes/form.inc on line 670.

Relevant code in form.inc:

      // We only check for trimmed string length being zero. 0 might be
      // a possible value with some field types, such as radio buttons, so
      // empty() is not usable here.
      if ($elements['#required'] && strlen(trim($elements['#value'])) == 0) { // #670
        form_error($elements, $t('!name field is required.', array('!name' => $elements['#title'])));
      }

Presumably the installer sets a field #value to an array, which does not seem to be ruled out by the API. form.inc should check the type here.

Comments

cburschka’s picture

Note: Drupal 6 has thorough type-checking there; this is a regression.

      // Make sure a value is passed when the field is required.
      // A simple call to empty() will not cut it here as some fields, like
      // checkboxes, can return a valid value of '0'. Instead, check the
      // length if it's a string, and the item count if it's an array.
      if ($elements['#required'] && (!count($elements['#value']) || (is_string($elements['#value']) && strlen(trim($elements['#value'])) == 0))) {
        form_error($elements, $t('!name field is required.', array('!name' => $elements['#title'])));
      }
cburschka’s picture

Status: Active » Closed (duplicate)

On examination of the CVS logs, it appears that this regression was already introduced to Drupal 6, but rolled back.

Issue was #117748: Trim required fields on validate. Note that this was the last commit on the file prior to D6 branching. I guess this went unnoticed, so the rollback was not completed in HEAD.

The issue actually is still open for Drupal 7 and (RTBsomething), so this is a duplicate.

vladimir.dolgopolov’s picture

Status: Closed (duplicate) » Active
vladimir.dolgopolov’s picture

Status: Active » Closed (duplicate)

oops, cross-post

cburschka’s picture

Cross post.