Forms Configuration

You can change the default form error messages in the configuration, in one place for the whole application.

Each message has a stable identifier, such as forms.length.min, and its text contains named placeholders like %count or %min, which Nette replaces with the values of the particular rule. These are the default messages:

forms:
	messages:
		forms.filled: 'This field is required.'
		forms.blank: 'This field should be blank.'
		forms.equal: 'Please enter %expected.'
		forms.notEqual: 'This value should not be %unexpected.'
		forms.length.min: 'Please enter at least %count characters.'
		forms.length.max: 'Please enter no more than %count characters.'
		forms.length.exact: 'Please enter exactly %count characters.'
		forms.length: 'Please enter a value between %min and %max characters long.'
		forms.count.min: 'Please select at least %count items.'
		forms.count.max: 'Please select no more than %count items.'
		forms.count.exact: 'Please select exactly %count items.'
		forms.count: 'Please select between %min and %max items.'
		forms.email: 'Please enter a valid email address.'
		forms.url: 'Please enter a valid URL.'
		forms.integer: 'Please enter a valid integer.'
		forms.numeric: 'Please enter a non-negative integer.'
		forms.float: 'Please enter a valid number.'
		forms.range.min: 'Please enter a value greater than or equal to %min.'
		forms.range.max: 'Please enter a value less than or equal to %max.'
		forms.range: 'Please enter a value between %min and %max.'
		forms.pattern: 'Please enter a value in the required format.'
		forms.enum: 'Please select a valid option.'
		forms.fileSize: 'The size of the uploaded file can be up to %limit bytes.'
		forms.mimeType: 'The uploaded file is in an unsupported format %type.'
		forms.image: 'The uploaded file must be an image in format %formats.'
		forms.upload: 'An error occurred during file upload.'
		forms.upload.maxFiles: 'The maximum allowed number of uploaded files is %count.'
		forms.selectBox: 'Please select a valid option.'
		forms.repeater.min: 'Please add at least %count items.'
		forms.repeater.max: 'Please add no more than %count items.'
		MaxPostSize: 'The uploaded data exceeds the limit of %limit bytes.'

The forms.length.* messages are used for text, while forms.count.* are used by controls with several selected values (CheckboxList, MultiSelectBox and multiple file upload), where the length rules count the selected items.

Instead of an identifier, you can also use the name of a validation rule, such as MinLength or Email. The text then applies to all messages of that rule, so MinLength covers both forms.length.min and forms.count.min. A text set for the identifier takes precedence.

Texts with numbers often need several plural forms in other languages (“1 item”, “2 items”). The configuration holds just one text, so leave plurals to the translator, which receives the number along with the message.

If you are not using the whole framework and therefore not even the configuration files, you can change the default error messages directly in the Nette\Forms\Validator::$messages array, with the same keys: Validator::$messages['forms.length.min'] = '...'.

version: 4.x 3.x 2.x