TextInputColumn custom validation error
Tables\Columns\TextInputColumn::make('baseShopItem.discount_price')
->label(__('validation.attributes.discount_price'))
->toggleable()
->rules([
fn (Forms\Get $get): \Closure => function (string $attribute, $value, \Closure $fail) use ($get) {
if ($get('baseShopItem.price') > $value) {
$fail("The {$attribute} is invalid.");
}
},
])
->extraInputAttributes(['class' => 'min-w-[68px]']),
i am getting.
App\Filament\Resources{closure}(): Argument #1 ($get) must be of type Filament\Forms\Get, string given
13 Replies
You cannot use
$get
in a table. There is no form.
Isn't the value injected through $state
or $value
maybe?The value is injected thats not the issue. I need to get the value of another text input column.
is there a solution for this
how can i pass $record in the custom rules
You can pass the record class in can't you?
Did you try
->rules(fn ($state) =>
?But he want's record to get another form value beyond the discount_price?
IMO a DataAware rule would be the right solution here.
Validation - Laravel 11.x - The PHP Framework For Web Artisans
Laravel is a PHP web application framework with expressive, elegant syntax. We’ve already laid the foundation — freeing you to create without sweating the small things.
Not used this yet... need to look into them myself
You slipped some JS syntax in there:
$record.price
😅🤣 updated
thankyou figured this out!