How to use custom rule with other field's data?
Hello All,
Could you please help me with this custom rule here?
i want to compare multiple field's data here to validate this field.
In custom_duration text field i want to check if custom_duration_select is hrs or min
as per the value selected, i want to validate the custom_duration number
i tried with a request post, but it is not getting validated.
Sorry, I am completely new to Livewire.
Thank you in advanced. π
TextInput::make('custom_duration')->label('')
->placeholder('Custom Duration')
->default(30)->numeric()
->requiredIf('event_duration','custom')
->rules([
function () {
return function (string $attribute, $value, Closure $fail) {
$c_d_select = Request::post('custom_duration_select');
if (($c_d_select === 'hrs' && $value > 12) || ($c_d_select === 'min' && $value > 720)) {
$fail("less than or equal to 12 hrs.");
}
};
},
]),
ButtonGroup::make('custom_duration_select')
->label('')
->options([
'min' => 'min',
'hrs' => 'hrs',
])
->default('min'),
0 Replies