XF 2.2 Required form element error message via phrase

asprin

Active member
So I've an entity set up like this:

PHP:
$structure->columns = [
    'sys_id' => ['type' => self::UINT, 'autoIncrement' => true],
    'title' => ['type' => self::STR, 'maxLength' => 40, 'required' => 'asp_fb_req_title'],
    'catg' => ['type' => self::STR, 'required' => 'asp_fb_req_catg', 'allowedValues' => array_keys($validCategories)],             
];

To test it, I keep both the fields empty and hit the submit button. I get the following output:

1675574995702.png

A couple of things are puzzling me:

(a) The error messages are not listed in the order the fields are shown on the page (In the form, first is the title and then the category). This is not a biggie though.

(b) The title's phrase asp_fb_req_title is being picked up but not the category's phrase asp_fb_req_catg. I've checked and double checked again. Both the phrases are present under the "Phrase" section. So unsure why a generic message is displayed instead of the intended phrase value.
 
Last edited:
Ok, looks like that generic phrase value might be coming from ValueFormatter class because of the presence of allowedValues.

Does this mean we won't be able to use our own phrase in this case? Or at least let user know which field we are referring to the in the error message?
 
Last edited:
Top Bottom