Taking a look at the docs and a couple issues here on the repo, I understand that relationships with Flexible Content are different from the usual ones used for nova, and to get a relationship working with this package, I would need to set a custom preset and resolver.
However, what would the resolver look like for a MorphTo relation.
What I'm trying to achieve is to have nova's default MorphTo field, with a select for the morphable_type and then a select for the morphable_id, and put it inside a Layout I can reuse.
class CustomPreset extends Preset
{
/**
* Execute the preset configuration
*
* @param Flexible $field
* @return void
* @throws Exception
*/
public function handle(Flexible $field): void
{
$field->button(Str::ucfirst(__('flexible.buttons.add.link')));
$field->addLayout(MorphableLayout::class)->resolver(CustomResolver:class);
}
}
class MorphableLayout extends Layout
{
public function fields(): array
{
return [
MorphTo::make('Relatable')->types([\App\Nova\User::class])
];
}
}
However I am not sure what the CustomeResolver class is supposed to return to get it to work with a MorphTo field.
Taking a look at the docs and a couple issues here on the repo, I understand that relationships with Flexible Content are different from the usual ones used for nova, and to get a relationship working with this package, I would need to set a custom preset and resolver.
However, what would the resolver look like for a MorphTo relation. What I'm trying to achieve is to have nova's default MorphTo field, with a select for the morphable_type and then a select for the morphable_id, and put it inside a Layout I can reuse.
However I am not sure what the CustomeResolver class is supposed to return to get it to work with a MorphTo field.
Thanks for the great package.
Running