Support from Acquia helps fund testing for Drupal Acquia logo

Comments

ezheidtmann’s picture

FileSize
2.57 KB

I originally uploaded the wrong features export statement. Fixed it.

alfaguru’s picture

I have been working on a similar issue and in the case I have been testing it seems to be related to Features. When the condition settings for a field were saved from the form at admin/structure/dependencies/edit/nn all was OK, but when they were imported from a feature we got the error.

After much sweat and debugging I tracked down the problem to conditional_fields_evaluate_dependency(), which includes the following code:

<?php
        // Some widgets store integers, but values saved in $dependency_values
        // are always strings. Convert them to integers because we want to do a
        // strict equality check to differentiate empty strings from '0'.
        if (is_int($values) && is_numeric($dependency_values)) {
          $dependency_values = (int) $dependency_values;
        }
?>

What I found was that the presumption in the comments was incorrect in the case in point. $dependency_values was a long, but $values was a string. For simplicity, I would propose the following amendment, which seems to be relatively safe and fixes the bug for us:

<?php
        // If one value is an integer and the other a string, 
        // convert to integers because we want to do a
        // strict equality check to differentiate empty strings from '0'.
        if (is_int($values) && is_numeric($dependency_values)) {
          $dependency_values = (int) $dependency_values;
        } elseif(is_int($dependency_values) && is_numeric($values)) {
          $values = (int)$values;
        }
?>

I don't have time to turn this into a patch right now. Will do so when time permits.

paramnida’s picture

I made a patch with the changes you suggested, but it didn't work for me. I get the following error:

An AJAX HTTP request terminated abnormally.
Debugging information follows.
Path: /system/ajax
StatusText: n/a
ResponseText: 
Skip to main content      
Error        The website encountered an unexpected error. Please try again later.                  
x
Error message
Warning: array_flip(): Can only flip STRING and INTEGER values! in DrupalDefaultEntityController-&gt;load() (line 173 of /srv/bindings/de4df69e7d894d5dabd379c52674fee1/code/includes/entity.inc).
EntityMalformedException: Missing bundle property on entity of type node. in entity_extract_ids() (line 7805 of /srv/bindings/de4df69e7d894d5dabd379c52674fee1/code/includes/common.inc).

ReadyState: undefined

This is my first patch, so hopefully I did it right. Any idea what went wrong?

fox_01’s picture

When i have 2 fields of the same field base (lets call it field_mycustom) inside different entities and they are referenced with inline entity form the function that field is disable on both fields but others work.

both entites have a different dependent field (selectlist) which work generelly but the field which is now twice at the form will wether hide or show up when the dependent field gets triggered

for testing purposes i renamed the field to field_mycustom2 (not the field label, i created a new field base) from the same type (text). now conditions work inside the the referenced entity and the top level entity. if i now add the field_mycustom again to the secondary entity only the condition for the field field_mycustom still works but the other not

For this patch #3 does not work

fox_01’s picture

fox_01’s picture

SocialNicheGuru’s picture

Status: Active » Needs review
Leksat’s picture

Issue summary: View changes
Status: Needs review » Reviewed & tested by the community
Leksat’s picture

Issue summary: View changes

Comment #2 describes the issue perfectly. Patch #3 works good (yet the code style needs to be updated).

dqd’s picture

Thanks for the reports and all the hard work in here. But due to inactivity in this issue for years and because of the upcoming EOL of Drupal 7 soon, I will close this issue while cleaning up the issue queue. Check the related issue top right, there is a fix to be committed soon for Drupal 8 and above.

dqd’s picture

Status: Reviewed & tested by the community » Closed (outdated)