cms
cms copied to clipboard
Form: File Maxsize Validation rule doesn't contain the attribute key
Bug description
When using max_filesize validation rule, it doesn't contain the attribute key. It only displays the ending message, "May not be greater than 3000 kilobytes." which isn't particularly helpful. Typically you would see with the validation rules the applied attribute key. e.g. "The User Profile Photo may not be greater than 3000 kilobytes."
I do not have modified validation keys (standard ones in Laravel)
How to reproduce
- Create a form
- Add a rule for file size < 3000 kB.
- Publish the form
- Complete the form and upload an image larger than 3000 kB.
- See error bag for message:
May not be greater than 3000 kilobytes.
Logs
Standard Laravel Validation file:
'max' => [
'numeric' => 'The :attribute may not be greater than :max.',
'file' => 'The :attribute may not be greater than :max kilobytes.',
'string' => 'The :attribute may not be greater than :max characters.',
'array' => 'The :attribute may not have more than :max items.',
],
Standard Statamic Validation language file:
'max' => [
'numeric' => 'May not be greater than :max.',
'file' => 'May not be greater than :max kilobytes.',
'string' => 'May not be greater than :max characters.',
'array' => 'May not have more than :max items.',
],
Versions
Statamic 3.3.6 Pro Laravel 9.17.0 PHP 8.1.6 optimoapps/statamic-bard-text-align 1.0.2
Installation
Fresh statamic/statamic site via CLI
Antlers Parser
No response
Additional details
No response
What's in your lang/en/validation.php file?
What's in your lang/en/validation.php file?
Hey @jasonvarga,
Thanks for the quick reply. I added that to the original post but nothing has been modified from the original Laravel installation and Statamic installation:
resources/lang/en/validation.php:
'max' => [
'numeric' => 'The :attribute may not be greater than :max.',
'file' => 'The :attribute may not be greater than :max kilobytes.',
'string' => 'The :attribute may not be greater than :max characters.',
'array' => 'The :attribute may not have more than :max items.',
],
I do not have a language file posted that overrides the default Statamic validation language file.
Okay thanks, I see the issue.
The custom image validation rules are currently using the statamic namespaced translations.
https://github.com/statamic/cms/blob/b2b108c6fda387ba02a25d1963bc4240987a6ae6/src/Fieldtypes/Assets/MaxRule.php#L25
It should only be doing that when inside the control panel.