Not a bug Hardcoded phrase in entity structure

kick

Well-known member
Affected version
2.1.8 Patch 2
PHP:
'priority' => ['type' => self::STR, 'required' => 'mst_please_enter_valid_priority',
                'allowedValues' => ['low', 'medium', 'high']
]
The phrase please_enter_valid_value is returned all the time.
PHP:
if (isset($columnOptions['allowedValues']) && !in_array($value, $columnOptions['allowedValues']))
        {
            $error = \XF::phrase('please_enter_valid_value');

            return false;
        }
 
I think you're conflating two concepts here.

Your "mst_please_enter_valid_priority" error would be displayed if no value is entered. It is the error given when a value is required but one has not been provided.

If a value other than the three allowed values is entered, it is true that you will get a generic error. That's not a bug though, that's just the way it is.

If you want more control over how errors appear in different scenarios, you would be better off adding a verifyPriority() method to your Entity and handling it in there. That is the preferable approach, but you can also use _preSave() if desired.
 
Back
Top Bottom