• This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn more.

How to require numeric fields using AutoValidator?


Active member
When using the AutoValidator, is there any way to make a numeric field required?

I know I can set a minimum value like:

array('type' => self::TYPE_UINT, 'min' => 1);

Which then will display the message:

"Please enter a number that is at least 1"

However, without the 'min' setting adding 'required' => true on its own does nothing.

I was hoping to be able to set a custom 'requiredError' message for this field.


Active member
So I figured out I can do this to the above array:

array('type' => self::TYPE_UINT, 'default' => 0, 'max' => 1000 , 'verification' => array('$this', '_verifyMyField'));


protected function _verifyMyField(&$myValue)
   if (!$myValue)
        $this->error('You must enter a maximum value.');
        return false;

    return true;
Which will display my custom required message in the overlay after submission.


However for the life of me I can't figure out how to get my message into the formValidationInlineError label like so:

Where could I be going wrong?


Well-known member
I'm pretty sure that's a part of the datawriter.

$datawriter->error('Please enter a number that is at least 1', 'your_field_name');


Active member
Thank you, the field name what I was missing! :)

Now, if only I can figure out why it doesn't want to work with a select element... does it work with all elements?

Again, I can get the pop-up message happening for that but even the basic validation without my function won't display any inline errors.


Active member
Can anyone please help? Do the inline validation errors work with select elements, or all elements for that matter?

Syndol 2.0

Active member
Do the inline validation errors work with select elements
I don't think you can do it with select elements.
You could however add a hidden text input box next to the select drop-down and pass that element's name to the error thus having the message show where you want.