- Issue created by @adriancid
- Merge request !4098Issue #3364343: Warning: Undefined array key "#access" in language_form_alter() โ (Open) created by adriancid
- last update
almost 2 years ago 30,335 pass - Status changed to Needs review
almost 2 years ago 3:17am 2 June 2023 - Status changed to Needs work
almost 2 years ago 2:38pm 2 June 2023 - ๐บ๐ธUnited States smustgrave
Seems like a bug that will need a test case showing the issue.
- ๐ฉ๐ชGermany donquixote
I think I have a better idea how this happens.
Normally, the $form['langcode'] is added by EntityFormDisplay::buildForm(), as a component.
Here the ['#access'] is set for every component.However, when using a custom form handler, perhaps for a custom entity type, perhaps the 'langcode' element is added in the form builder itself. In that case, if the developer does not set the '#access', they will see this message.
So the blame could be on the developer who creates a custom entity form. But it is also not clear what is the "contract" for adding this element in a custom form.
@adriancid Do you know which entity and which form this is?
- ๐ฌ๐ทGreece vensires
I fell into this issue while tampering the node form's
$form['langcode']['widget']
without checking if it exists. @donquixote's comment helped me identify this. After I added my code in aif (isset($form['langcode']['widget'])) {... }
the error was gone.So, I am coming back with the question of... do we really want to fix this? I don't have a clear answer on that...
- ๐ฎ๐ณIndia anandhi karnan Chennai
anandhi karnan โ made their first commit to this issueโs fork.
- Merge request !9466issue #3364343 Warning: Undefined array key #access in language_form_alter โ (Open) created by anandhi karnan
- Status changed to Needs review
7 months ago 10:12am 11 September 2024 - Status changed to Needs work
7 months ago 2:31pm 11 September 2024 - ๐บ๐ธUnited States smustgrave
Think before we just put an isset check we document why it's empty and verify aren't masking a larger issue.
- ๐ฎ๐ณIndia anandhi karnan Chennai
@smustgrave The warning "Undefined array key '#access'" is difficult to reproduce in environments where the #access key is consistently set. Consequently, the warning does not typically manifest under standard conditions. However, it is important to address this issue to adhere to strict coding standards and ensure robust error handling.
- ๐บ๐ธUnited States smustgrave
Making an error go away without knowing the root cause doesnโt seem right.