Problem/Motivation

Entity type: node

Field type: paragraph reference (multiple)

Dependency configuration:

  • Condition: Value
  • Input mode: Insert value from widget
  • Form state: Visible
  • Effect: Show/hide

Getting this notice:

Notice: Undefined index: #type in conditional_fields_attach_dependency() (line 282 of /app/drupal/web/modules/contrib/conditional_fields/conditional_fields.module)

It appears this is an issue with adding dependencies on paragraph reference fields.

On line 282 of the dev module:

    if ($dependent['#type'] == 'date') {
      array_pop($dependent_parents);
    }

But there is no #type on paragraph reference dependencies.

Note: this ticket applies to both the dev and alpha branches.

Steps to reproduce

  • Create a visibility condition on a paragraph reference field
  • Verify you receive the notice

Proposed resolution

Check for the #type array key.

Remaining tasks

User interface changes

API changes

Data model changes

CommentFileSizeAuthor
#6 3223457-6.patch684 bytessokru
#5 3223457-check-type.patch632 bytesjasa
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

Laura Johnson created an issue. See original summary.

ltrain’s picture

Version: 4.x-dev » 4.0.0-alpha1
ltrain’s picture

Issue summary: View changes
Status: Active » Needs review
jasa’s picture

StatusFileSize
new632 bytes

I had the same problem.
Adding isset for "#type" key.

sokru’s picture

StatusFileSize
new684 bytes

Confirming this fixed the issue with paragraphs, attached a patch to apply to latest dev-commit.

simohell’s picture

Status: Needs review » Reviewed & tested by the community

Tested with 4.0.0-alpha2 that is currently the same as 4.x-dev

  • Laura Johnson authored c5446fc3 on 4.x
    Issue #3223457 by Laura Johnson, jasa, sokru: Notice: Undefined index: #...
saurabh-2k17’s picture

Status: Reviewed & tested by the community » Fixed

Thank you everyone for your efforts on this.

Status: Fixed » Closed (fixed)

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