© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
FilamentF
Filament•3y ago
Gustave

MorphToSelect in Repeater (Mdue to MorphMany)

Hi all !
I'm trying to develop a planning tool where I've Tasks (or Milestones) and each may have dependencies (predecessors or successors) which are also Tasks (or Milestones).
To do that, both models extends an 'Activity' class where we can find the following relation :

public function predecessors()  {
        return $this->morphMany(Dependency::class, 'successor');
    }
public function predecessors()  {
        return $this->morphMany(Dependency::class, 'successor');
    }


In the Dependency class, I retrieve the model by a morphTo relation :

public function successor()
    {
        return $this->morphTo();
    }
public function successor()
    {
        return $this->morphTo();
    }


So now I try to deals with a form Modal (I'm already in relationManager) using Repeater (for the MorphMany relation) then a MorphToSelect (for the morphOne). I tried several things but for me the most relevant would be :

Forms\Components\Repeater::make('predecessors')
 ->relationship()
 ->schema([
   Forms\Components\MorphToSelect::make('successor')
    ->types([
      Forms\Components\MorphToSelect\Type::make(Milestone::class)->titleColumnName('name'),
      Forms\Components\MorphToSelect\Type::make(Task::class)->titleColumnName('name'),
     ]),
Forms\Components\Repeater::make('predecessors')
 ->relationship()
 ->schema([
   Forms\Components\MorphToSelect::make('successor')
    ->types([
      Forms\Components\MorphToSelect\Type::make(Milestone::class)->titleColumnName('name'),
      Forms\Components\MorphToSelect\Type::make(Task::class)->titleColumnName('name'),
     ]),


But this gives an error : Call to undefined method App\Models\Task::successor()
I thought I had understood that inside the repeater I was dealing with the relationship of the predecessors, not the record, but I was obviously wrong. Could someone point me in the right direction?
regards
Filament banner
FilamentJoin
A powerful open source UI framework for Laravel • Build and ship admin panels & apps fast with Livewire
20,307Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

MorphMany Relation buggy in relationshipManager.
FilamentFFilament / ❓┊help
3y ago
relationship select morphMany
FilamentFFilament / ❓┊help
3y ago
Set MorphToSelect to a value in mount()
FilamentFFilament / ❓┊help
3y ago
TextInpiut with morphMany relationship
FilamentFFilament / ❓┊help
2y ago