Enhance TagsInput validation: ensure at least one item is required for non-empty arrays
This commit is contained in:
@@ -90,14 +90,22 @@ class FilamentInput
|
||||
break;
|
||||
|
||||
case 'tags':
|
||||
return TagsInput::make($setting->name)
|
||||
$input = TagsInput::make($setting->name)
|
||||
->label($setting->label ?? $setting->name)
|
||||
->placeholder($setting->placeholder ?? '')
|
||||
->required($setting->required ?? false)
|
||||
->disabled($setting->disabled ?? false)
|
||||
->hint($setting->hint ?? '')
|
||||
->hintColor('primary')
|
||||
->helperText($setting->description ?? '');
|
||||
|
||||
// For required TagsInput, we need to validate the array has at least one item
|
||||
// Filament's required() alone considers empty arrays as "filled"
|
||||
if ($setting->required ?? false) {
|
||||
$input->required()
|
||||
->rules(['array', 'min:1']);
|
||||
}
|
||||
|
||||
return $input;
|
||||
break;
|
||||
|
||||
case 'text':
|
||||
|
||||
Reference in New Issue
Block a user