0

i have an entity reference (7.x-1.5) select-list within a checkout pane which is being used to allow the user to attach a child to a product during a checkout process.

The user can add multiple "child" under their account via field collections

The user adds a product to their cart, then checks out. During the checkout they can select a "Child" to be attached to the registrations.

My issue is when a user goes to checkout, the select list is constantly growing in values the user(from every user). The current user does not have access to these fields so the select list values simply say: -Restricted access-.

enter image description here

I assumed this would only show values from the logged in user, but apparently, the widget grabs ALL values from every user but hides the data the current user does not have access to. I simply need to hide all data which says -Restricted access- this data so if the user has not entered any "child" field collection data, there will be no option to select from.

Has anyone ever dealt with this issue, and what options are there to fix this? I can simply use an autocomplete widget to solve this issue, but this is poor UX in my opinion.

4
  • 2
    Can't you change the reference widget to use Views as a filter to provide the options? Then in Views, provide this users UID as a contextual argument to only get their own relationships instead of every user.
    – Kevin
    Commented Oct 30, 2018 at 20:21
  • 1
    (Provided by the Views reference filter module in case you don't already have it)
    – Clive
    Commented Oct 30, 2018 at 20:36
  • 1
    @Kevin It would be worth mentioning the module that functionality comes from, but otherwise that would make a good answer
    – Clive
    Commented Oct 30, 2018 at 20:36
  • Oh my god I had no idea this functionality was built in. It's working now thanks a bunch guys! I created an entity reference view of my field collection items and used the current logged in user UID to only show the values pertaining to their account. Kevin feel free to answer the question thanks again !!
    – DMAC
    Commented Oct 30, 2018 at 20:38

1 Answer 1

1

You change the reference widget to use Views as a filter to provide the options with Views Reference Filter. Then in Views, provide this users UID as a contextual argument to only get their own relationships instead of every user.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.