Select required validations fails while it's set?

I have a wizard component, where the second step is dynamic based on a select from the first step, Code that returns the fields:
public static function getSettings(): array
{
return [
Select::make('settings.datasets')
->label(__('labels.datasets'))
->options(Dataset::pluck('name', 'id'))
->required()
->searchable(),
Select::make('settings.interaction_list')
->label(__('labels.interaction_list'))
->options(InteractionList::pluck('name', 'id'))
->helperText(__('filament.resources.tasks.interaction_list_helper'))
->searchable(),
TextInput::make('settings.similarity')
->label(__('labels.similarity_threshold'))
->suffix('%')
->numeric()
->step(1)
->minValue(0)
->maxValue(100)
->required()
->default(75),
TextInput::make('settings.min_cluster_size')
->label(__('labels.min_cluster_size'))
->suffix(__('labels.items'))
->numeric()
->step(1)
->required()
->minValue(1)
->default(2),
TextInput::make('settings.cluster_report_name') //todo make unique
->label(__('labels.cluster_report_name'))
->required()
->default('Cluster Report'),

];
}
public static function getSettings(): array
{
return [
Select::make('settings.datasets')
->label(__('labels.datasets'))
->options(Dataset::pluck('name', 'id'))
->required()
->searchable(),
Select::make('settings.interaction_list')
->label(__('labels.interaction_list'))
->options(InteractionList::pluck('name', 'id'))
->helperText(__('filament.resources.tasks.interaction_list_helper'))
->searchable(),
TextInput::make('settings.similarity')
->label(__('labels.similarity_threshold'))
->suffix('%')
->numeric()
->step(1)
->minValue(0)
->maxValue(100)
->required()
->default(75),
TextInput::make('settings.min_cluster_size')
->label(__('labels.min_cluster_size'))
->suffix(__('labels.items'))
->numeric()
->step(1)
->required()
->minValue(1)
->default(2),
TextInput::make('settings.cluster_report_name') //todo make unique
->label(__('labels.cluster_report_name'))
->required()
->default('Cluster Report'),

];
}
9 Replies
DanielvdSpoel
DanielvdSpoelOP13mo ago
And then this wizard code:
protected function getSteps(): array
{
return [
Step::make('Worker')
->label(__('labels.worker'))
->icon('heroicon-m-server')
->schema([
Select::make('worker_id')
->label(__('labels.worker'))
->relationship('worker', 'name')
->preload()
->searchable()
->required(),
Select::make('type')
->label(__('labels.type'))
->options(TaskType::class)
->required()
->live(),
Textarea::make('notes')
->label(__('labels.notes'))
->columnSpanFull()
])->columns(),
Step::make('Settings')
->label(__('labels.settings'))
->icon('heroicon-m-adjustments-horizontal')
->schema(function (Get $get) {
if (!$get('type')) {
return [];
}
$taskClass = TaskType::from($get('type'))->getClass();
return $taskClass->getSettings();
})->columns(),
];
}
protected function getSteps(): array
{
return [
Step::make('Worker')
->label(__('labels.worker'))
->icon('heroicon-m-server')
->schema([
Select::make('worker_id')
->label(__('labels.worker'))
->relationship('worker', 'name')
->preload()
->searchable()
->required(),
Select::make('type')
->label(__('labels.type'))
->options(TaskType::class)
->required()
->live(),
Textarea::make('notes')
->label(__('labels.notes'))
->columnSpanFull()
])->columns(),
Step::make('Settings')
->label(__('labels.settings'))
->icon('heroicon-m-adjustments-horizontal')
->schema(function (Get $get) {
if (!$get('type')) {
return [];
}
$taskClass = TaskType::from($get('type'))->getClass();
return $taskClass->getSettings();
})->columns(),
];
}
If i put the array of settings directly into the wizard step it works directly Bumb bumb 2
toeknee
toeknee13mo ago
I think I've seen this too where there steps are built into a form opposed to as part of ->steps() on an action or a form.
DanielvdSpoel
DanielvdSpoelOP13mo ago
yeah it's really weird like i get it not being auto filled but it's weird it just don't send it together with the other data
toeknee
toeknee13mo ago
Have you mounted a form fill?
DanielvdSpoel
DanielvdSpoelOP13mo ago
I'm using filament panel, I didn't add it in additionely, but I kinda expected the panels package to do that?
toeknee
toeknee13mo ago
If it's in the panel and this is part of a resource it should fill yes
DanielvdSpoel
DanielvdSpoelOP13mo ago
yeah so that's not working, propably becouse the fields aren't defined when fill is executed which is fine, like i can go without the auto fill for certain feelds but i do want them to work
toeknee
toeknee13mo ago
That makes sense, so you would need to hydrate them in as Livewire only works on mount. So you can render all the fields? and hide them conditionally?
DanielvdSpoel
DanielvdSpoelOP13mo ago
hmm, i guess that would work
Want results from more Discord servers?
Add your server