DevMike
checkbox list: Allow exactly one selection (like Radiobutton)
I have made a form with Checkbox lists, for it gives me the option to use relationships to pivot tables.
But instead of noticing the user via label to select only one option, I would like to only allow one option. (Just like Radiobutton, which can't be used in lack of relationship option or like SelectBox, which can't be used in Lack of BelongsToMany relationship.)
Could be a good idea to implement an Option as "->SingleSelectionOnly()", which deselects all other options when one item being clicked.
3 replies
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:
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)
9 replies