Form field in relationship to pivot table
Hello, just one question with edititing a resource of admin panel:
I have a common user model with id as primary field and name, language etc.
Ther is a pivot subtable user_details with a hasMany relationship from users -> hasMany(user_details) identified by user_id.
user-details has just 4 columns: id, user_id, field, value.
Task: I want to add to the user-form single rows of user_details as seperated fixed form-fields.
Until now I have added a relationshipManager to user_details giving me a table with every entry according to user_id, what is nice so far.
But I need to build a custom user-form where I can place each possible field of "user_details" identified by the value of column field as the name of the formfield itself.
My approach:
I am having a fieldset with relationship to user_details, trying to display the field 'value'
In my form of UserResource.php:
But it gives me just an TypeError:
Is that possible? Thanks for any advice for I am new to filament and little used to laravel.
PHP 8.1.23
Laravel 9.52.10
Filament v2.17.50 (project is not updateable for me)
I have a common user model with id as primary field and name, language etc.
Ther is a pivot subtable user_details with a hasMany relationship from users -> hasMany(user_details) identified by user_id.
user-details has just 4 columns: id, user_id, field, value.
Task: I want to add to the user-form single rows of user_details as seperated fixed form-fields.
Until now I have added a relationshipManager to user_details giving me a table with every entry according to user_id, what is nice so far.
But I need to build a custom user-form where I can place each possible field of "user_details" identified by the value of column field as the name of the formfield itself.
My approach:
I am having a fieldset with relationship to user_details, trying to display the field 'value'
In my form of UserResource.php:
But it gives me just an TypeError:
Filament\Forms\Components\Fieldset::relationship(): Argument #2 ($condition) must be of type Closure|bool, array given, called in /var/www/html/app/Filament/Resources/UserResource.phpHow do I correctly connect the Fieldset with the related row of user_details where 'field' = 'nameOfField' ?
Is that possible? Thanks for any advice for I am new to filament and little used to laravel.
PHP 8.1.23
Laravel 9.52.10
Filament v2.17.50 (project is not updateable for me)