This module is shaping up to be a really excellent piece of work. Your time and effort are appreciated - this solves a lot of problems for me.

That being said, once a view is selected, if I try to remove it by selecting "None", I get the error

The referenced entity (view_none) does not exist.

I'm pretty sure this has to do with the default settings in the field config - there's a "None" option for the "View" field, but no "None" option for the "Display ID" field.

Please see the attached screenshots for further clarification.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

fenns created an issue. See original summary.

NewZeal’s picture

That is entirely due to the view field. The select widget needs more work. In the meantime, switch over to the autocomplete and delete contents of the field to remove a view.

NewZeal’s picture

Assigned: Unassigned » joekers

Joekers, assigning this to you.

Jonah Fenn’s picture

@New Zeal, just to follow up, things work fine when I'm using the autocomplete widget.

joekers’s picture

@fenns thanks for reporting the issue. The select widget definitely needs some more work, I'll take a look at this as soon as I can.

NewZeal’s picture

Joekers, if you check out the dev code, or pull from the repo, you will see I have dealt with most of the issues. There is still a problem with the isEmpty() part of the field. Also, I extracted duplicated code into a Trait.

joekers’s picture

Nice work!! Thanks for looking at those. I'll have a look at the isEmpty() now.

I was going to suggest that we extract the code into a trait :)

NewZeal’s picture

Actually, on second thoughts, the code would be cleaner if isEmpty() tested for _none rather than some version of null. Then we can remove the other hacks that I put in place.

joekers’s picture

Status: Active » Needs review

I have made some changes on a separate branch so that we can review them: none_option_throws-2832518

I've basically removed the extra none options that were added and the default being removed. Instead there is a check in the setValue method so that if none is selected then $value['target_id'] is set to NULL. I believe this is the way that the autocomplete field handles empty (by setting the target_id to NULL), and therefore there are no values stored in the field.

I've done some light testing and it seems to be working well but I welcome any feedback / suggestions.

joekers’s picture

I've merged this branch into 8.x-1.x as I believe it fixes the issue. I've attached a patch of the changes made. If there's any more problems with it please report back :)

Jonah Fenn’s picture

@joekers - my apologies for dropping the ball on this one. I appreciate your diligence with it.

I've tested your merge and did so in a views reference field that was nested inside of a rather complex paragraphs structure and it worked great. I flipped the widget back and forth a few times between the select list and the autocomplete and couldn't produce an error.

Thanks for sticking with this!

joekers’s picture

Status: Needs review » Fixed

Glad it's working for you, thanks for reporting the issue and for testing out the fix!

joekers’s picture

Assigned: joekers » Unassigned

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.