Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

yong940221's avatar

Nova BelongsToMany Problem

I trying to set value to belongstomany field when Attach, but unfortunately not working

Nova Resource

BelongsToMany::make('Merchants', 'merchants', \App\Nova\MerchantConfiguration\Merchant::class)
            // ->searchable()
            ->default(1)
            ->resolveUsing(function(){
                return 1;
            })
            ->fillUsing(function(){
                return 1;
            })
            ->withMeta(['belongsToId' => 1, 'belongsToManyId' => 1, 'value' => 1])

JS

var aa = document.querySelector('form[data-form-unique-id]');
var formUniqueId = aa.dataset.formUniqueId;
Nova.$emit(formUniqueId + '-merchants-value', 1);

Any idea how to set value to belongsToMany?

Or can I replace the dropdown selection (when "Attach") to other input?

0 likes
0 replies

Please or to participate in this conversation.