When I edit a menu link I after I've enabled domain access support for that specific menu I get an empty fieldset with no domains available.

The following error shows:

Notice: Undefined index: widget in Drupal\domain\DomainElementManager->disallowedOptions() (line 130 of modules/contrib/domain/domain/src/DomainElementManager.php).
Drupal\domain\DomainElementManager->disallowedOptions(Object, Array) (Line: 59)
Drupal\domain\DomainElementManager->setFormOptions(Array, Object, 'field_domain_access') (Line: 47)
domain_menu_access_form_menu_link_content_form_alter(Array, Object, 'menu_link_content_menu_link_content_form') (Line: 501)
Drupal\Core\Extension\ModuleHandler->alter('form', Array, Object, 'menu_link_content_menu_link_content_form') (Line: 830)
Drupal\Core\Form\FormBuilder->prepareForm('menu_link_content_menu_link_content_form', Array, Object) (Line: 272)
Drupal\Core\Form\FormBuilder->buildForm('menu_link_content_menu_link_content_form', Object) (Line: 74)
Drupal\Core\Controller\FormController->getContentResult(Object, Object)
call_user_func_array(Array, Array) (Line: 123)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 576)
Drupal\Core\Render\Renderer->executeInRenderContext(Object, Object) (Line: 124)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext(Array, Array) (Line: 97)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}()
call_user_func_array(Object, Array) (Line: 153)
Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object, 1) (Line: 68)
Symfony\Component\HttpKernel\HttpKernel->handle(Object, 1, 1) (Line: 57)
Drupal\Core\StackMiddleware\Session->handle(Object, 1, 1) (Line: 47)
Drupal\Core\StackMiddleware\KernelPreHandle->handle(Object, 1, 1) (Line: 99)
Drupal\page_cache\StackMiddleware\PageCache->pass(Object, 1, 1) (Line: 78)
Drupal\page_cache\StackMiddleware\PageCache->handle(Object, 1, 1) (Line: 47)
Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object, 1, 1) (Line: 50)
Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object, 1, 1) (Line: 23)
Stack\StackedHttpKernel->handle(Object, 1, 1) (Line: 657)
Drupal\Core\DrupalKernel->handle(Object) (Line: 19)

Modules installed:
Domain access: 8.x-1.0-alpha11
Domain Country Path: 8.x-1.0

Comments

Erik.Johansson created an issue. See original summary.

hbensalem’s picture

+1 following

yivanov’s picture

+ 1
This practically makes the module not usable.

yang.wilby’s picture

+1, I have the same problem

juliakoelsch’s picture

Same here. My version of the Domain module is 8.x-1.0-alpha13, exact same issue.

lukasss’s picture

For this reason, we can say that the module does not work at all!!!

pifagor’s picture

Do you have problem on 8.x-1.0-alpha2 version?

pifagor’s picture

lukasss’s picture

yes and 8.x-1.x-dev also...

pifagor’s picture

can you write all the dependencies and step-by-step instruction to reproduce the problem?

juliakoelsch’s picture

I am able to reproduce on a https://simplytest.me/ site with the Domain Access and Domain Menu Access Modules:

After launch, install these modules:
* Domain
* Domain Access
* Domain Alias
* Domain Alpha Updates
* Domain Configuration
* Domain Content
* Domain Menu Access

After module installation, configure 2 domains in Domain Records settings. Go to Domain Menu settings, select Main Navigation menu.

Create a node assigned to one domain, adding that node to the main menu. Go to Structure -> Menus -> Main Navigation -> Edit the newly added link. The PHP notice detailed in the issue is in the Recent Messages log, and no domains appear in the "DOMAIN" block of the edit link page.

andypost’s picture

Very probably that caused by missing default form display for menu link core.entity_form_display.menu_link_content.menu_link_content.default

mykhailo.levchenko’s picture

Does someone have any news about this issue?

lukasss’s picture

#12 work for me

pifagor’s picture

Hello @lukasss.
If you tested the method of solving the problem, would be grateful if you added the patch.

andypost’s picture

Just add form display for menu link entity, basically you need to add the file I pointed in #12

mykhailo.levchenko’s picture

Hi @andypost,
Could you please tell me where exactly I need to do this?

christian le fournis’s picture

I would be also interested to know where exactly to copy the file.

lukasss’s picture

just import this:

langcode: en
status: true
dependencies:
  config:
    - field.field.menu_link_content.menu_link_content.domain_access
  module:
    - link
    - menu_link_content
id: menu_link_content.menu_link_content.default
targetEntityType: menu_link_content
bundle: menu_link_content
mode: default
content:
  domain_access:
    type: options_buttons
    weight: 21
    settings: {  }
    third_party_settings: {  }
    region: content
  langcode:
    type: language_select
    weight: 2
    settings: {  }
    third_party_settings: {  }
    region: content
  title:
    type: string_textfield
    weight: -5
    settings:
      size: 60
      placeholder: ''
    third_party_settings: {  }
    region: content
  translation:
    weight: 10
    region: content
hidden: {  }

in core.entity_form_display.menu_link_content.menu_link_content.default

Here: .../admin/config/development/configuration/single/import

christian le fournis’s picture

Thank you Lukasss !!

christian le fournis’s picture

StatusFileSize
new97.52 KB

I imported the configuration but I still can't see any option under the menu setting?

lukasss’s picture

Have you tried to reset the cache?

christian le fournis’s picture

It's working now, thank you.

erik.johansson’s picture

My fieldset is still empty after importing the config and clearing the cache. @extrem94 how did you solve this issue?

arulraj’s picture

My Fieldset is still empty after doing the all the procedure.
How to resolve this issue?

Only local images are allowed.

davps’s picture

Version: 8.x-1.0-alpha1 » 8.x-1.x-dev
Status: Active » Needs work

@Erik.Johansson, @arulraj follow the steps below:

  1. Disable module:drush pmu domain_menu_access -y
  2. Import config as described in comment #2937271-19: Empty domains list on menu link.
  3. Enable module: drush en domain_menu_access -y
  4. Ensure that required menu selected here /admin/config/domain/domain_menu_access/config
  5. Clear cache: drush cr

Config import solve this issue, but it would be better to provide more flexible workaround.
As described before, menu_link_content hasn't UI to manage fields (Form Display) and part of code in domain_access_confirm_fields function wasn't executed:

    // Tell the form system how to behave. Default to radio buttons.
    if ($display = \Drupal::entityTypeManager()->getStorage('entity_form_display')->load($entity_type . '.' .  $bundle . '.default')) {
      $display->setComponent(DOMAIN_ACCESS_FIELD, [
        'type' => 'options_buttons',
        'weight' => 40,
      ])->setComponent(DOMAIN_ACCESS_ALL_FIELD, [
        'type' => 'boolean_checkbox',
        'settings' => ['display_label' => 1],
        'weight' => 41,
      ])->save();
    }
erik.johansson’s picture

@davps I can confirm that I got the module to work after I followed your steps in a clean installation. Thanks!

Is it a possible solution to set the domain_access form widget to checkboxes so that we don't have to import config in order for the module to work. The module is pretty much broken as it is now.

davps’s picture

Assigned: Unassigned » davps

Is it a possible solution to set the domain_access form widget to checkboxes so that we don't have to import config in order for the module to work. The module is pretty much broken as it is now.

@Erik.Johansson I'm working on it. I'll try to make patch asap.

d.novikov’s picture

If nothing helps, try to run drush dre after configuration import from #19. It resolved the issue for me.

hydra’s picture

StatusFileSize
new28.97 KB

You might need to add the domain_access fields to the menu item
At /admin/structure/menu/manage/main/fields I was missing these fields

screen

sorabh.v6’s picture

I can see the domains list after #19 but that does not work.

I added a new link in the menu and selected one domain only for that link. But I can see that link on all domains.

@Hydra I cannot manage fields for menu, how are you able to add?

I am using Drupal 8.6.4

hydra’s picture

@sorabh.v6 If you can see the domain list at the menu link, you don't have the issue described here! Lucky you :)
It sound like you still need to replace the menu block. Domain menu access provides a custom menu block as far as I remember - the drupal default menu block does not respect the access settings set by the module.

sorabh.v6’s picture

@Hydra Thanks for the reply, I can see the block after clearing cache. And the domain menu access is working for me.

davps’s picture

This patch contains test which should failed, because domain access fields couldn't be installed for menu links

davps’s picture

Assigned: davps » Unassigned
Status: Needs work » Needs review
StatusFileSize
new5.07 KB

This patch contains fixes and test should passed.

davps’s picture

Need to re-roll tests when they will be added for 8.x-1.x branch.

I'll appreciate for reviews and manual testing.

  • pifagor committed cd62e57 on 8.x-1.x authored by davps
    Issue #2937271 by davps, extrem94, Hydra, lukasss, Erik.Johansson,...
pifagor’s picture

Status: Needs review » Fixed

Status: Fixed » Closed (fixed)

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