Changing the required error message – “This field is required”

To change the required message, pass in an additional parameter to the addValidator line, containing an array of options with your message, the syntax and array nesting is important. Copying the code here is a good idea, just be sure to change $element to match your element’s unique name.

1
2
3
$element->addValidator('required', array(
    'messages' => array('required' => 'This is a required field')
));
$element->addValidator('required', array(
    'messages' => array('required' => 'This is a required field')
));

NOTE: if you are having any problems with this, you can change the message directly in the file lib/Quform/Validator/Required.php near the top of the file. The same goes for the other validators.

Still having trouble? Head over to the forums.

Forums