Problem/Motivation
When using the Radios Other element type in a Webform and configuring conditional visibility on another field based on the value of the Radios Other element, the following PHP deprecation warning is triggered:
Using null as an array offset is deprecated, use an empty string instead in
/webform/src/Plugin/WebformElement/OptionsBase.php
The warning originates from the following line in OptionsBase.php:
return (isset($options[$value])) ? $value : NULL;
Steps to reproduce
- Create a Webform.
- Add a Radios Other element with multiple options.
- Add another field, such as a text field.
- Configure conditional visibility on the second field based on the selected value of the Radios Other element.
- Open the Webform and trigger the conditional visibility evaluation.
Proposed resolution
Add a check to ensure that $value is not NULL before using it as an array offset.
For example:
return (isset($value) && isset($options[$value])) ? $value : NULL;
This would prevent the deprecation warning when $value is NULL while preserving the existing behavior for valid option values.
Remaining tasks
User interface changes
API changes
Data model changes
Comments
Comment #2
prashant.cSubmitted an MR and patch to fix the issue, kindly review.
Comment #3
liam morlandPlease create a merge request.