using associative array for table/form schema array

is there any concern in using associative array for form/table schema, eg:
// default form schema
function defaultRegistrationForm(){
return [
'name' => TextInput::make('name'),
'email' => TextInput::make('email'),
];
}

function getRegistrationFormSchema(){
// handle form schema customization
}

// form
$form->schema($this->getRegistrationFormSchema())
// default form schema
function defaultRegistrationForm(){
return [
'name' => TextInput::make('name'),
'email' => TextInput::make('email'),
];
}

function getRegistrationFormSchema(){
// handle form schema customization
}

// form
$form->schema($this->getRegistrationFormSchema())
and then I will have some api to customize the schema fields, eg:
RegistrationForm::add(fn() => ['mobile' => TextInput::make('mobile'));
RegistrationForm::before('name', ['salutation => ...]);
RegistrationForm::add(fn() => ['mobile' => TextInput::make('mobile'));
RegistrationForm::before('name', ['salutation => ...]);
this may also extend to any methods in filament that return array such as getHeaderActions array etc is this a pattern that Filament would advise against with?
Solution:
i cant imagine any immediate issues, but i cannot guarantee that the key will not be lost at some point in the form process and replaced with a nunber
Jump to solution
4 Replies
wyChoong
wyChoongOP14mo ago
Hi @Dan Harrin sorry for pinging you but I think the post is pushed far too low for you to notice. And I think this would be best if can be answered by core/you
Solution
Dan Harrin
Dan Harrin14mo ago
i cant imagine any immediate issues, but i cannot guarantee that the key will not be lost at some point in the form process and replaced with a nunber
Dan Harrin
Dan Harrin14mo ago
if it works for you, i think its safe to continue
wyChoong
wyChoongOP14mo ago
In my potential use case I think the key only matters before filament process the schema, so I guess should be fine until it doesn’t 😂
Want results from more Discord servers?
Add your server