Form: Adding user-defined pivot data to belongsToMany relationship
I have a form like this:
allowedTargets
is a many-to-many-relationship of my Model. Each target has a pivot column allowed_file_extensions
which accepts an array of file extensions as strings.
Using a TextInput
inside the pivotData()
-method is not doing anything. But it is also not documented and was just an example what I already tried. I want the user be able to add allowed_file_extensions as pivot data on the create page of my Model. So he is able to create the parent model directly with the relationship and the specific pivot data. Is that possible?
I also tried it using a RelationManager but it seems like RelationManagers don't show up on the resource create page.1 Reply
For now I would like to go with a RelationManager on the Edit page so I can edit the pivot data later. But I have problems using a repeater:
This is the form in my
AllowedTargetsRelationManager
:
These are typical data in the database of the allowed_file_extensions
column:
["json"]``
default:
[]`
Anyone has an idea?
I also have a pivot model that casts the JSON column to an array: