\_form_validate
function
Performs validation on form elements. First ensures required fields are completed, #maxlength is not exceeded, and selected options were in the list of options given to the user. Then calls user-defined validators.

Performs validation on form elements. First ensures required fields are completed, #maxlength is not exceeded, and selected options were in the list of options given to the user. Then calls user-defined validators.

Comments

drastik’s picture

Why isn't the !is_array() check done before trying to get strlen on a potential array? I get an error when using Min / Max Views exposed filters that also have a maxlength attribute because of this.

What's wrong with:

if (isset($elements['#maxlength']) && !is_array($elements['#value']) && drupal_strlen($elements['#value']) > $elements['#maxlength']) {

Or going to further measures to handle it even better (iterate and check the array contents strlen)?