I am trying to output form validation errors when you hover over the “X” in the dropped off file in Dropzone.
What I get:
How can I make the object Object
output the actual error message from the form validation? I can alert the error message but can’t actually show the error message upon hovering over the x.
My js file:
JavaScript
x
17
17
1
Dropzone.options.fileupload = {
2
maxFilesize: 20,
3
4
init: function () {
5
thisDropzone = this;
6
this.on("error", function (file, responseText) {
7
8
$.each(responseText, function (index, value) {
9
alert( value); //this shows the alert of the error message
10
11
});
12
13
14
});
15
}
16
};
17
My controller:
JavaScript
1
4
1
$this->validate($request, [
2
'file' => 'max:20000',
3
]);
4
Advertisement
Answer
I have fixed my issue.
To anyone who might have the same issue.
I fixed it by simply putting $('.dz-error-message').text(value);
Full code:
JavaScript
1
12
12
1
Dropzone.options.fileupload = {
2
maxFilesize: 50,
3
init: function () {
4
thisDropzone = this;
5
this.on("error", function (file, responseText) {
6
$.each(responseText, function (index, value) {
7
$('.dz-error-message').text(value);
8
});
9
});
10
}
11
};
12