I am using Laravel version 5.2.45. Currently I have some troubles with translating required_if rule. When I am using the required_if,field,value it's printing out the fields value in the error validation message, which in this case is either 1 or 0. that is not very readable.
For example:
Field 1 is required if type is 0
Would like:
Field 1 is required if type is default
Is there any way to translate the values of the rquired_if value/:value?
Controller:
$customerVal = Validator::make($request->all(), [
'field1' => 'required_if:type,0',
'field2' => 'required_if:type,0',
]);
View:
@if (count($errors) > 0)
<div class="modalMsg alert">
<ul>
@foreach ($errors->all() as $error)
<li>{{ $error }}</li>
@endforeach
</ul>
</div>
@endif
I can see that Laravel has this in the language section:
'required_if' => ':attribute is required when :other are :value.',
So it's basically :value I need to translate(dynamically). I have tried below, but that does not replace 0:
'attributes' => [
'field1' => [
'0' => 'test'
]
]