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

CommentFileSizeAuthor
#2 3626744-radios-other-element.patch534 bytesprashant.c

Issue fork webform-3626744

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

prashant.c created an issue. See original summary.

prashant.c’s picture

Status: Active » Needs review
StatusFileSize
new534 bytes

Submitted an MR and patch to fix the issue, kindly review.

liam morland’s picture

Status: Needs review » Needs work
Issue tags: +Needs merge request

Please create a merge request.