You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
A rule in attribute data-nette-rules generates an array (rule as Form::MimeType) or object (rule Form::Image) into arg. In the case of an object, the validation javascript then fails with Uncaught TypeError: arg.replace is not a function
//Form::MimeType
data-nette-rules='[{"op":":fileSize","msg":"The size of the uploaded file can be up to 134217728 bytes.","arg":134217728},{"op":":mimeType","msg":"The File must be image in format JPEG, GIF, PNG or WebP.","arg":["image/gif","image/jpeg","image/png","image/webp","image/bmp"]}]'
//Form::Image
data-nette-rules='[{"op":":fileSize","msg":"The size of the uploaded file can be up to 134217728 bytes.","arg":134217728},{"op":":image","msg":"The uploaded file must be image in format JPEG, GIF, PNG or WebP.","arg":{"0":"image/gif","1":"image/jpeg","2":"image/png","3":"image/webp","5":"image/bmp"}}]'
Steps To Reproduce
composer.json
{
"require": {
"nette/forms": "3.2.3"
}
}
index.php
<?php
require_once './vendor/autoload.php';
use Nette\Forms\Form;
$f = new Form();
// works as expected
$f->addUpload('test_mime')->addRule(Form::MimeType,'The File must be image in format JPEG, GIF, PNG or WebP.', ["image/gif","image/jpeg","image/png","image/webp","image/bmp"]);
//js throw: Uncaught TypeError: arg.replace is not a function
$f->addUpload('test_image')->addRule(Form::Image);
$f->addSubmit('submit','Submit');
?>
<!DOCTYPE html>
<head>
<title>test</title>
<script src="vendor/nette/forms/src/assets/netteForms.js"></script>
</head>
<body>
<?php
$f->render();
?>
</body>
</html>
Expected Behavior
The arg in both rules should be generated in the same way or netteForms.js should be able to handle the object.
The text was updated successfully, but these errors were encountered:
dg
added a commit
that referenced
this issue
May 12, 2024
Version: 3.2.3
Bug Description
A rule in attribute
data-nette-rules
generates an array (rule as Form::MimeType) or object (rule Form::Image) intoarg
. In the case of an object, the validation javascript then fails withUncaught TypeError: arg.replace is not a function
forms/src/assets/netteForms.js
Line 529 in 94f43f0
Steps To Reproduce
composer.json
index.php
Expected Behavior
The
arg
in both rules should be generated in the same way ornetteForms.js
should be able to handle the object.The text was updated successfully, but these errors were encountered: