Laravel Version: 5.5.20
Voyager Version: 1.0.7
PHP Version: 7.1.10
Database Driver & Version: MySQL 5.7.20
Validation not working when trying to add a new record of a type which have some validation rules.
{
"validation": {
"rule": "required",
"messages": {
"required": "This :attribute field is a must."
}
}
}
$.each(e.errors,function(t,n){0===Object.keys(e.errors).indexOf(t)&&$("html, body").animate({scrollTop:$("[name='"+t+"']").parent().offset().top-$("nav.navbar").height()+"px"},"fast"),$("[name='"+t+"']").parent().addClass("has-error"),$("[name='"+t+"']").parent().append("<span class='help-block' style='color:#f96868'>"+n+"</span>")})},error:function(){$(n).unbind("submit").submit()}})})})},,,function(e,t,n){var i,r;"function"==typeof Symbol&&Symbol.iterator;
to this:
$.each(e.errors,function(t,n){0===Object.keys(e.errors).indexOf(t)&&$("html, body").animate({scrollTop:$("[data-name='"+t+"']").parent().offset().top-$("nav.navbar").height()+"px"},"fast"),$("[data-name='"+t+"']").parent().addClass("has-error"),$("[data-name='"+t+"']").parent().append("<span class='help-block' style='color:#f96868'>"+n+"</span>")})},error:function(){$(n).unbind("submit").submit()}})})})},,,function(e,t,n){var i,r;"function"==typeof Symbol&&Symbol.iterator;
and the problem solved partially but I get another problem that the error message shown and still shown despite of the field is not empty.
I have the same problem
I have the same problem extented bread
Same problem I encountered here. Any solution?
Same problem after migrate the database with self generated tables or columns, So i think the problem is that voyager didn't accept migration from outside Voyager UI.
Related to #2236
Same issue. Please mention a workaround until we get fix, if anyone has.
@dattz check out #2236. I mention a dirty workaround. Basically you just have to lowercase display names (Assuming they are identical) like name/Name order/Order.
@Victor-emil Oh! Thanks! Great temporary fix. 馃憤
Go toline number 129 of vendor/tcg/voyager/src/Http/Controllers/Controller.php and replace display_name to field as below :
if (!is_array($options->validation->rule)) {
// $rules[$row->display_name] = explode('|', $options->validation->rule);
$rules[$row->field] = explode('|', $options->validation->rule);
} else {
// $rules[$row->display_name] = $options->validation->rule;
$rules[$row->field] = $options->validation->rule;
}
I hope this will help you
@krishna-bhatta, please don't suggest overwriting code under vendor/. At least not without providing a VERY good reason. I also recommend providing the warning that the change will be overwritten with any updates.
you can use this as work around
public function validateBread($request,$data) {
$rules = [];
$messages = [];
foreach ($data as $row) {
$options = json_decode($row->details);
if (isset($options->validation)) {
if (isset($options->validation->rule)) {
if (!is_array($options->validation->rule)) {
$rules[$row->field] = explode('|', $options->validation->rule);
} else {
$rules[$row->field] = $options->validation->rule;
}
}
if (isset($options->validation->messages)) {
foreach ($options->validation->messages as $key => $msg) {
$messages[$row->field.'.'.$key] = $msg;
}
}
}
}
return Validator::make($request, $rules, $messages);
}
paste it to your controller to override the base Controller.
This was also fixed in #2660
This issue has been automatically locked since there has not been any recent activity after it was closed. If you have further questions please ask in our Slack group.
Most helpful comment
you can use this as work around
paste it to your controller to override the base Controller.