Problem/Motivation

MenuLinkDefaultForm::extractFormValues() is documented as returning the plugin definition, but the ID (part of the definition) is not included.

Proposed resolution

Make sure the returned definition includes a value for ID and every other definition key.

Remaining tasks

  • \Drupal\Core\Menu\Form\MenuLinkFormInterface::extractFormValues should document that it has to return the plugin ID as well
  • Write some unit test for \Drupal\Core\Menu\Form\MenuLinkDefaultForm::extractFormValues to ensure the plugin ID is returned

User interface changes

n/a

API changes

n/a

Data model changes

Additional array keys present in return value

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

pwolanin created an issue. See original summary.

pwolanin’s picture

Issue summary: View changes
Status: Active » Needs review
FileSize
1.29 KB
Wim Leers’s picture

pwolanin’s picture

Small fix to make sure the ID is consistent.

pwolanin’s picture

Plus some code comments

dawehner’s picture

I'm wondering whether we can have some form of test coverage to ensure this is actually working as expected?

dawehner’s picture

Status: Needs review » Needs work

Note: We should also make it clear in the documentation that the method is supposed to return the plugin ID as well.

dawehner’s picture

Linked the related issue.

dawehner’s picture

Issue summary: View changes
jibran’s picture

Issue tags: +Needs tests

We also need tests.

rrrob’s picture

FileSize
2.28 KB
572 bytes

Add \Drupal\Core\Menu\Form\MenuLinkFormInterface::extractFormValues documentation.

dawehner’s picture

Status: Needs work » Needs review
Issue tags: -Needs tests
FileSize
4.47 KB
2.2 KB

Added a test as well

jibran’s picture

Status: Needs review » Reviewed & tested by the community

Thanks for the tests.

catch’s picture

Status: Reviewed & tested by the community » Fixed

Committed/pushed to 8.1.x and cherry-picked to 8.0.x. Thanks!

  • catch committed af1f11e on 8.1.x
    Issue #2660486 by pwolanin, dawehner, rrrob: MenuLinkDefaultForm::...

  • catch committed cad24a7 on 8.0.x
    Issue #2660486 by pwolanin, dawehner, rrrob: MenuLinkDefaultForm::...
rrrob’s picture

@pwolanin in my tests, $form_state->getValue('id') is sometimes null, overwriting $new_definition['id'] which actually has a valid id.

In what cases were you seeing $new_definition['id'] not being present?

Status: Fixed » Closed (fixed)

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