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

Reflexive Relation Bug #17

Closed luke0x90 closed 4 years ago

luke0x90 commented 4 years ago

Description:

Nova disables fields when creating a relationship. The issue I am having is when i created a 'related' relationship that links two items together it disables both of the drop-downs. I can inspect the element in browser and then it functions as required and the relationship can still be made. Is this a bug or is there a way of overriding it?

I have an observer set up to create and remove the reflexive version of these entries.

Screen Shot 2019-12-13 at 17 55 30 Screen Shot 2019-12-13 at 17 55 15

Schema:

venue:
    id
    etc

related_venues
    venue1_id
    venue2_id

Model Relationships

RelatedVenue
________
    public function main_venue()
    {
        return $this->belongsTo('App\Venue', 'venue1_id');
    }
    public function sec_venue()
    {
        return $this->belongsTo('App\Venue', 'venue2_id');
    }
Venue
________
    public function relatedTo1()
    {        return $this->hasMany('App\RelatedVenue', 'venue1_id');
    }

    public function relatedTo2()
    {        return $this->hasMany('App\RelatedVenue', 'venue2_id');
    }

Nova Resource

Venue
________
           HasMany::make('Related Venues', 'relatedTo1'),
Related Venue
________
            BelongsTo::make('Main Venue','main_venue', 'App\Nova\Venue')->prepopulate(),
            BelongsTo::make('Related Venue', 'sec_venue', 'App\Nova\Venue')->prepopulate(),
mikebronner commented 4 years ago

@priceluke Would you mind testing this again in version 1.2.0 and let me know if that fixed the issue for you? Thanks!

mikebronner commented 4 years ago

This should now be fixed as of release 1.2.0. Please make sure to change the repo name before updating, see readme. Thanks!