Closed rumeau closed 3 years ago
+1
I've managed to make it work adding a method setResourceParentClass() to explicitly set the resourceParentClass property on the dependant field.
@rumeau Could you please leave us here a segment of code that you used to work around the problem? I'm stuck on a solution for this! Thanks!
Hello @newtongamajr
Actually i've just added a method to NovaBelongsToDepend
/**
* @param $parentResourceClass
* @return self
*/
public function setResourceParentClass($parentResourceClass)
{
$this->resourceParentClass = $parentResourceClass;
return $this;
}
And pass the resource name explicitly to that method
NovaBelongsToDepend::make(__('Subcategory'), 'subcategory', Subcategory::class)
->setResourceParentClass(self::class)
->dependsOn('category');
Actually im not sure if thats the only think i did because i've finally ended up creating my own custom field.
I have uploaded to github and packagist in case you want to give it a try.
I haven't tested it in every scenario but it does what i needed, and you can work over it.
https://github.com/rumeau/belongsto-depend
composer require rumeau/belongsto-depend
Greetings
@orlyapps Is this something that will be looked at at all? Thanks! 😄
@rumeau , Thanks for your work around, and I'll give a try on your new package!
+1
Hello everyone. Thanks for the issue. We currently dont have any nova 3.0 installation. So we would be very happy about a pull request! I can merge it asap as new version!
Hello, i have upgraded to Nova 3.0 but im seeing no issues? Can you please explain whats happing?
@orlyapps , I'm having the same issue. The list simple don't display the names:
And when I select one, the console log shows:
Here are my code
NovaBelongsToDepend::make(__('Tenant'), 'tenant', NovaTenant::class)
->placeholder(__('Select a Tenant'))
->options(Tenant::all())
I'm using Laravel v7.20.0 and Laravel Nova 3.7.1
Does it support Nova 3?
It fails loading options on dependant field as resourceParentClass is never set