Set min value dinamically

i have 2 integer values to fill first one must be not greather than the 2nd one and 2nd one must be not smaller than 1st one This is what im trying, but im missing something and idk what it is :/
Forms\Components\TextInput::make('min_int')
->live()
->numeric()
->rule('integer')
->inputMode('numeric')
,
Forms\Components\TextInput::make('max_int')
->live()
->numeric()
->rule('integer')
->inputMode('numeric')
->maxValue(function (Get $get) {
return $get('min_int');
})
,
Forms\Components\TextInput::make('min_int')
->live()
->numeric()
->rule('integer')
->inputMode('numeric')
,
Forms\Components\TextInput::make('max_int')
->live()
->numeric()
->rule('integer')
->inputMode('numeric')
->maxValue(function (Get $get) {
return $get('min_int');
})
,
3 Replies
ericmp #2
ericmp #2OP14mo ago
also tried to use ->afterStateUpdated(function (Get $get, Set $set, ?string $old, ?string $state) { but with that i only got to set the value, but not the max value 🤔 this must be ez, but idk how to do it (,:
toeknee
toeknee14mo ago
try:
->maxValue(function (Get $get) {
return (int) $get('min_int');
})
->maxValue(function (Get $get) {
return (int) $get('min_int');
})
ericmp #2
ericmp #2OP14mo ago
i was getting the wrong attr, now works:
->minValue(function (Get $get): int {
return (int) $get('min_int');
})
->minValue(function (Get $get): int {
return (int) $get('min_int');
})
thanks for the help

Did you find this page helpful?