Field content['#options'] missing after upgrade to core 10.2.3

Created on 21 February 2024, 4 months ago
Updated 23 February 2024, 4 months ago

Link fields, and likely other text fields, are missing content['#options'].
We discovered this on our site after upgrading from core v10.2.2 -> core v10.2.3.

Specifically for us, link fields with additional attributes are no longer rendering properly. We are currently using the link_attributes module to add these additional attributes, which seems to be failing because the Field content['#options'] no longer exists.



Here is an example of a link field object in drupal core 10.2.2:

0 array:2 [β–Ό
"content" => array:4 [β–Ό
"#type" => "link"
"#title" => "Meeting Documents"
"#options" => array:2 [β–Ό
"attributes" => array:2 [β–Ά]
"external" => true
]
"#url" =>
Drupal\Core
\
Url {#3654 β–Ά}
]
"attributes" =>
Drupal\Core\Template
\
Attribute {#3815 β–Ό
#storage: []
}
]

Here is an example of the same field in drupal core 10.2.3:
Notice how item.content[#options'] is missing.

0 array:2 [β–Ό
"content" => array:3 [β–Ό
"#type" => "link"
"#title" => "Meeting Documents"
"#url" =>
Drupal\Core
\
Url {#3775 β–Ά}
]
"attributes" =>
Drupal\Core\Template
\
Attribute {#3699 β–Ό
#storage: []
}
]

πŸ’¬ Support request
Status

Closed: works as designed

Version

10.2 ✨

Component
OptionsΒ  β†’

Last updated 27 days ago

No maintainer
Created by

πŸ‡ΊπŸ‡ΈUnited States cdupree

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

  • Issue created by @cdupree
  • πŸ‡ΊπŸ‡ΈUnited States cdupree

    Is the ['#options'] array generated through core or is it generated through the modules that use it? Please advise if this bug is being reported in the wrong place, thanks.

  • Status changed to Needs work 4 months ago
  • πŸ‡ΊπŸ‡ΈUnited States cdupree
  • πŸ‡¦πŸ‡ΊAustralia larowlan πŸ‡¦πŸ‡ΊπŸ.au GMT+10

    Which formatter are you using?

  • πŸ‡ΊπŸ‡ΈUnited States cdupree

    I'm not sure, I'm not a seasoned Drupal dev. How can I determine which formatter I'm using?

  • πŸ‡¦πŸ‡ΊAustralia larowlan πŸ‡¦πŸ‡ΊπŸ.au GMT+10

    See related issue, might be a problem in your theme
    What sort of content are you using the link field on- menu links?

  • πŸ‡¦πŸ‡ΊAustralia larowlan πŸ‡¦πŸ‡ΊπŸ.au GMT+10

    Linking where the bug was fixed in core

  • Status changed to Needs review 4 months ago
  • πŸ‡ΊπŸ‡ΈUnited States COBadger

    It's not clear to me where this was addressed in 10.2.x, so I'm attaching a patch that I re-rolled from the 11.x patch for use against 10.2.3 in case it's useful to anyone.

    Marking this as 'Needs review', though perhaps this issue could be closed if it's addressed in the linked issue.

  • Status changed to Needs work 4 months ago
  • The Needs Review Queue Bot β†’ tested this issue.

    While you are making the above changes, we recommend that you convert this patch to a merge request β†’ . Merge requests are preferred over patches. Be sure to hide the old patch files as well. (Converting an issue to a merge request without other contributions to the issue will not receive credit.)

  • Status changed to Needs review 4 months ago
  • πŸ‡¦πŸ‡ΊAustralia larowlan πŸ‡¦πŸ‡ΊπŸ.au GMT+10

    Link attributes module is still passing tests on 10.2.3

    If you have this problem it is likely you have a theme preprocess hook or template that is accessing link['optiions'] the fix in core was to remove duplicates between link['optiions'] and link['url']->get options()

    You should be using the options on the url object, not the render array

  • πŸ‡ΊπŸ‡ΈUnited States cdupree

    Yes, the linked issue #3423171 was a duplicate of this problem.
    We did a find and replace in our theme and replaced all instances of ['#options']['attributes'] with ['#url'].options['attributes'] which solved our issue.

    Thank you!

  • Status changed to Closed: works as designed 4 months ago
  • πŸ‡ΊπŸ‡ΈUnited States cdupree
Production build 0.69.0 2024