We are using the Wetkit distro (version 1.9) and have installed Conditional Fields. I recently updated to the most recent dev version (7.x-3.0-alpha1+15-dev) and applied a patch (https://www.drupal.org/node/1464950#comment-9874453). Now, every time I create a new node that uses conditional fields dependencies, I see 2 notices:

Notice: Undefined property: stdClass::$field_alternate_title_for_slide in locale_field_entity_form_submit() (line 443 of /path/to/site/modules/locale/locale.module).
Notice: Undefined property: stdClass::$field_slide_show_image in locale_field_entity_form_submit() (line 443 of /path/to/site/modules/locale/locale.module).

If I remove the conditional fields dependencies, the notices no longer appear. Is anyone else experiencing this issue?

Comments

drupal.pupil’s picture

I just set up a fresh 7.37 core installation, with Conditional Fields [conditional_fields-7.x-3.x-dev.tar.gz + conditional_fields_fixed_multiple_field_collection_fields_1464950-63_0 (1).patch], Entity [entity-7.x-1.6.tar.gz], Entity Translation [entity_translation-7.x-1.0-beta3.tar.gz], i18n [i18n-7.x-1.12.tar.gz] and Variable [variable-7.x-2.5.tar.gz] installed and enabled.

How to generate the messages:

  1. create a new content type with field translation enabled
  2. add a boolean field and a text field
  3. set up dependencies so that the text field is set to visible and required if the boolean is checked
  4. create a new node, and on save you'll get this error:
    • Notice: Undefined property: stdClass::$field_text in locale_field_entity_form_submit() (line 443 of /data/www/core/modules/locale/locale.module).
  5. try to translate said node, you'll get these 2 errors:
    • Notice: Undefined index: #field_parents in conditional_fields_element_after_build() (line 262 of /data/www/core/sites/all/modules/contrib/conditional_fields/conditional_fields.module).
    • Warning: Invalid argument supplied for foreach() in conditional_fields_flatten_array() (line 1988 of /data/www/core/sites/all/modules/contrib/conditional_fields/conditional_fields.module).
robin.ingelbrecht’s picture

Got same issue, following

joel_osc’s picture

I have this issue as well... I think it has to do with conditional fields removing the fields from the submitted values and locale assuming that the form_state values is a complete version of the entity. I have what I would call a "workaround" that is fairly simplistic in that it just checks to make sure the field value is there before assigning it in line 443 of the locale module. This issue could potentially be moved to that modules queue, but I would like the conditional fields maintainer's thoughts first to see if this is the correct approach given that locale is part of core.

Here is my workaround on line 441:

 429 function locale_field_entity_form_submit($entity_type, $form, &$form_state ) {
 430   if (field_has_translation_handler($entity_type, 'locale')) {
 431     $entity = (object) $form_state['values'];
 432     $current_language = entity_language($entity_type, $entity);
 433     list(, , $bundle) = entity_extract_ids($entity_type, $entity);
 434 
 435     foreach (field_info_instances($entity_type, $bundle) as $instance) {
 436       $field_name = $instance['field_name'];
 437       $field = field_info_field($field_name);
 438       $previous_language = $form[$field_name]['#language'];
 439       // Handle a possible language change: new language values are inserted,
 440       // previous ones are deleted.
 441       if ($field['translatable'] && $previous_language != $current_language && isset($entity->{$field_name}[$previous_language])) {
 442         $form_state['values'][$field_name][$current_language] = $entity->{$field_name}[$previous_language];
 443         $form_state['values'][$field_name][$previous_language] = array();
 444       } 
 445     } 
 446   } 
 447 } 

Any and all community input is welcome!