When a form specifies '#required' => TRUE a user can still enter blank information by way of spaces. This is bad as allowing spaces as titles, private message subject lines, etc, etc. brakes the links that these things should be accessed by.

Eg. a node title or private message subject is usually clickable, but if these entities are allowed to be entered as spaces they can no longer be clicked and opened.

So in addition to using the empty function one should trim and check that.

Patch for form.inc below:

532c532,534
<       if ($elements['#required'] && empty($elements['#value']) && $elements['#value'] !== '0') {
---
>       if ($elements['#required'] &&
>           (empty($elements['#value']) || trim($elements['#value']) == '') &&
>           $elements['#value'] !== '0') {

Comments

quicksketch’s picture

Status: Needs review » Closed (fixed)

Forms and survey modules are no longer being maintained, use Webform module instead.

---Closing down issue queue of survey module---