When controlled field is Title and Target field is text field and set to required than I see the below issue.

Error: Call to a member function getCardinality() on null in conditional_fields_get_state() (line 216 of /Users/sites/drupal/modules/contrib/conditional_fields/conditional_fields.api.inc) #0 /Users/sites/drupal/modules/contrib/conditional_fields/conditional_fields.api.inc(85): conditional_fields_get_state(Object(Drupal\Core\Entity\Entity\EntityFormDisplay), 'title', Array, Array) #1 [internal function]: conditional_fields_form_after_build(Array, Object(Drupal\Core\Form\FormState)) #2 /Users/sites/drupal/core/lib/Drupal/Core/Form/FormBuilder.php(1064)

Comments

gg24 created an issue. See original summary.

gg24’s picture

Assigned: gg24 » Unassigned
Status: Active » Needs review
StatusFileSize
new1.8 KB

Please review the attached patch.

Thanks!

gg24’s picture

StatusFileSize
new825 bytes

This patch will work for 8.x-1.0-alpha2 version.

Thanks!

gg24’s picture

Version: 8.x-1.0-alpha2 » 8.x-1.x-dev
gg24’s picture

StatusFileSize
new862 bytes

This patch will work for 8.x-1.x-dev version.

Thanks!

guptahemant’s picture

Status: Needs review » Reviewed & tested by the community

hi @gg24,
Tested both of your patches in #3 and #5 and both are working fine marking the issue as RTBC.

riddhi.addweb’s picture

StatusFileSize
new65.6 KB
new27.37 KB

@gg24, Thanks for the patch it works well, as i checked it over simplytest.me PFA screenshots as results of after patch & before patch.
Also, Thanks for explaining the case, it helps me to reach the issue easily.

colan’s picture

Status: Reviewed & tested by the community » Needs work
+++ b/conditional_fields.api.inc
@@ -217,7 +217,9 @@ function conditional_fields_get_state(EntityFormDisplayInterface $form_display,
+    // if $field_config is not null.

This comment isn't necessary as it's obvious from the code in the line below.

+++ b/conditional_fields.api.inc
@@ -217,7 +217,9 @@ function conditional_fields_get_state(EntityFormDisplayInterface $form_display,
+    if($field_config)

There's a missing space after the if, and the enclosing brackets are missing. Please review the coding standards.

gg24’s picture

Status: Needs work » Needs review
StatusFileSize
new10.17 KB

Hi @colan,

I made the changes suggested and corrected syntax issues in the respective file too.
Please review.

Thanks!

colan’s picture

Status: Needs review » Needs work

All of the array stuff is done in #2881629: Convert module to use short array syntax (new coding standard).. Let's just focus on the main issue here so as not to confuse things.

  • colan committed c91cf72 on 8.x-1.x authored by gg24
    Issue #2921741 by gg24, colan: Stop fetching the cardinality if there...
colan’s picture

Status: Needs work » Fixed

Committed a cleaner variation of the above patch so that we could get this in sooner than later.

Status: Fixed » Closed (fixed)

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