validator proceed even if field is not required and value is empty

Created on 28 May 2018, over 6 years ago
Updated 13 September 2024, 2 months ago

On form submission, error message is displayed, even if the field is not filled.

$form['myfield'] = [
      '#title' => 'My title',
      '#type' => 'textfield',
      '#validators' => [
        ['rule' => 'numeric', 'error' => 'Error message for field %field.'],
      ],
      '#filters' => array('trim', 'numeric')
    ];

If I force unrequirement for this field with '#required' => FALSE, message always appears.

πŸ› Bug report
Status

Fixed

Component

Code

Created by

πŸ‡«πŸ‡·France corentin.crouvisier Paris

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.71.5 2024