mikebronner / nova-prepopulate-searchable

A tool to allow BelongsTo searchable fields to be pre-populated with data
MIT License
37 stars 21 forks source link

Not showing "+ Create" on BelongTo component, Nova v2.10.0 #18

Closed sabid closed 4 years ago

sabid commented 4 years ago

New feature of Nova v2.10.0: Added ability for users to create related resources on BelongsTo and MorphsTo relation type on create and update views.

67989063-ba291e80-fbff-11e9-8f71-d5b75e0fbfff

This plugin overwrite the default nova component BelongTo

Nova.booting((Vue, router) => {
    Vue.component('form-belongs-to-field', Tool);
})
Jon78 commented 4 years ago

Good find.

philipbaginski commented 4 years ago

I have the same problem. After plugin was installed I was not able to see +Create button and with Trashed is displayed. Plus nullable() for BelongsTo is not working. How to fix it?

HELP!!!!! :-)

mikebronner commented 4 years ago

Hi @sabid @Jon78 @philipbaginski, would you guys mind testing release 1.2.0 and let me know if that fixes it for you?

Jon78 commented 4 years ago

Issue is still there. Furthermore, if a field has a default value, the other options are not shown.

This is the field we would like to be prepopulated:

BelongsTo::make('Kleur', 'color', Color::class)
->hideFromIndex()
->searchable()
->rules('nullable')
->updateRules('required')
->showCreateRelationButton()
->default(static function () {
    return \App\Models\Color::inRandomOrder()->first()->id;
})
mikebronner commented 4 years ago

@Jon78 Thank you for following up on this. I will check this out and see if it can be addressed.

Jon78 commented 4 years ago

Great!

Yeah I could live with the showCreateRelationButton not working with this specific field, just not all BelongsTo-fields 😀️

Maybe this package should be a custom field in stead of adding functionality to Nova's?

mikebronner commented 4 years ago

Oh, be sure to use the new repo genealabs/nova-prepopulate-searchable in your composer.json when testing, sorry I forgot to mention that. I changed namespaces when taking over maintenance.

mikebronner commented 4 years ago

This issue is now fixed in release 1.3.0. Please be sure to change the repo name in your composer.json file before updating.

mikebronner commented 4 years ago

@Jon78 See issue #7 regarding the list being empty with preselected items.

Jon78 commented 4 years ago

This issue is now fixed in release 1.3.0. Please be sure to change the repo name in your composer.json file before updating.

Installation fails because of dependency issues:

composer require genealabs/nova-prepopulate-searchable
Using version ^1.3 for genealabs/nova-prepopulate-searchable
./composer.json has been updated
Loading composer repositories with package information
     Updating dependencies (including require-dev)         
Your requirements could not be resolved to an installable set of packages.

  Problem 1
    - Installation request for laravel/nova (locked at v2.12.0, required as ^2) -> satisfiable by laravel/nova[v2.12.0].
    - genealabs/nova-prepopulate-searchable 1.3.0 requires laravel/nova >=3.8.4 -> satisfiable by laravel/nova[dev-master].
    - genealabs/nova-prepopulate-searchable 1.3.1 requires laravel/nova >=3.8.4 -> satisfiable by laravel/nova[dev-master].
    - Conclusion: don't install laravel/nova dev-master
    - Installation request for genealabs/nova-prepopulate-searchable ^1.3 -> satisfiable by genealabs/nova-prepopulate-searchable[1.3.0, 1.3.1].

Installation failed, reverting ./composer.json to its original content.

Will try on a branch with Nova 3.* later.

Jon78 commented 4 years ago

Seems to be working under Nova 3.8.4!

mikebronner commented 4 years ago

Ah, yes, I forgot to add that requirement to the readme. Will do that now. :)