フォームの設定

設定では、既定のフォームのエラーメッセージを変えられます。

forms:
	messages:
		Equal: 'Please enter %s.'
		NotEqual: 'This value should not be %s.'
		Filled: 'This field is required.'
		Blank: 'This field should be blank.'
		MinLength: 'Please enter at least %d characters.'
		MaxLength: 'Please enter no more than %d characters.'
		Length: 'Please enter a value between %d and %d characters long.'
		Email: 'Please enter a valid email address.'
		URL: 'Please enter a valid URL.'
		Integer: 'Please enter a valid integer.'
		Numeric: 'Please enter a non-negative integer.'
		Float: 'Please enter a valid number.'
		Min: 'Please enter a value greater than or equal to %d.'
		Max: 'Please enter a value less than or equal to %d.'
		Range: 'Please enter a value between %d and %d.'
		MaxFileSize: 'The size of the uploaded file can be up to %d bytes.'
		MaxPostSize: 'The uploaded data exceeds the limit of %d bytes.'
		MimeType: 'The uploaded file is not in the expected format.'
		Image: 'The uploaded file must be image in format JPEG, GIF, PNG or WebP.'
		Nette\Forms\Controls\SelectBox::Valid: 'Please select a valid option.'
		Nette\Forms\Controls\UploadControl::Valid: 'An error occurred during file upload.'
		Nette\Forms\Controls\CsrfProtection::Protection: 'Your session has expired. Please return to the home page and try again.'

日本語訳は次のとおりです。

forms:
	messages:
		Equal: '%s を入力してください。'
		NotEqual: 'この値は %s であってはいけません。'
		Filled: 'この項目は必須です。'
		Blank: 'この項目は空でなければなりません。'
		MinLength: '%d 文字以上で入力してください。'
		MaxLength: '%d 文字以内で入力してください。'
		Length: '%d 文字以上 %d 文字以下で入力してください。'
		Email: '正しいメールアドレスを入力してください。'
		URL: '正しい URL を入力してください。'
		Integer: '正しい整数を入力してください。'
		Numeric: '0 以上の整数を入力してください。'
		Float: '正しい数値を入力してください。'
		Min: '%d 以上の値を入力してください。'
		Max: '%d 以下の値を入力してください。'
		Range: '%d 以上 %d 以下の値を入力してください。'
		MaxFileSize: 'アップロードできるファイルの大きさは %d バイトまでです。'
		MaxPostSize: 'アップロードされたデータが %d バイトの上限を超えています。'
		MimeType: 'アップロードされたファイルは想定された形式ではありません。'
		Image: 'アップロードされたファイルは JPEG、GIF、PNG、WebP のいずれかの形式の画像でなければなりません。'
		Nette\Forms\Controls\SelectBox::Valid: '正しい選択肢を選んでください。'
		Nette\Forms\Controls\UploadControl::Valid: 'ファイルのアップロード中にエラーが起きました。'
		Nette\Forms\Controls\CsrfProtection::Protection: 'セッションの有効期限が切れました。トップページに戻ってやり直してください。'

フレームワーク全体を使っておらず、したがって設定ファイルも使っていないなら、既定のエラーメッセージは Nette\Forms\Validator::$messages 配列で直接変えられます。

バージョン: 4.x