how dynamically add form text Input or spatieTag into resource based on non related model

Hi ,
the scenario is I've spatietag but i've added TagsTypes as new model / table and added tags_type_id to tags and its working fine as i've resource to create types and save models/resourcesse which should show /use this type in pivot table (reporting_tags_model) and another resource to create tags in specific type.
now my problem is in other resource lets name it transactionResource , in this transaction resource i need to add SpatiTag or even normal textInput to be created dynamically for each Tag Types that load them from pivot table ( table (reporting_tags_model which have tag_type_id and the model_name )) as if i added 5 tags types for transaction model i need 5 inputs in my transactions resource.
Solution
In the form, it'll probably look like this:
$tagInputs = [];

foreach ($tagTypes as $type) {
    $tagsInput[] = SpatieTagInput::make(/* make a unique field name from $type */);
}

return $form
    ->schema([
        ...$tagInputs,
        // other fields
    ])
Was this page helpful?