This error occurs on every content type that is not utilzing a conditional state, on a fresh(ish) install of Drupal 7.15.

Notice: Undefined property: stdClass::$content in field_conditional_state_entity_view() (line 136 of /path/to/site/sites/all/modules/field-conditional-state/field_conditional_state.module).

The log contains the above error, and the following warning:
Warning: Invalid argument supplied for foreach() in field_conditional_state_entity_view() (line 136 of /path/to/site/sites/all/modules/field-conditional-state/field_conditional_state.module).

If this is not relevant or has been fixed in 7.x-1.x-dev please ignore.

Edit: My install of Drupal is not completely fresh. I have ctools and a custom module turned on, but I am not interacting with Field Conditional State directly. My custom module has an implementation of hook_node_presave() to modify the node's path based on a field's content.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

carwin’s picture

Issue summary: View changes

I was wrong about not having any non-core modules turned on. This edit reflects that.

carwin’s picture

Status: Active » Closed (cannot reproduce)

I tried to go back and fix this error, but I can no longer reproduce it. Marking it as such.

Drethic’s picture

Status: Closed (cannot reproduce) » Needs review

I had this same issue. I am using a Media: Youtube field when the error flies. Any other layout of my node doesn't have any issues. I took at look at $entity and it doesn't have a content entry. I used this code to fix it:

<?php
  if(!empty($entity->content)) {
      foreach ($entity->content as $field_name => $field_content) {
        if (isset($field_content['#bundle'])) {
          $field_conditions = field_conditional_state_get_field_conditions($field_name, $field_content['#bundle']);
          $data = array($type, $view_mode, $langcode);
          drupal_alter('field_conditional_state_entity_view', $field_conditions, $entity, $data);
          if ($field_conditions) {
            foreach ($field_conditions as $condition) {
              $lang = $field_content['#language'];
              $control_field_name = $condition['control_field'];
              $control_values = $entity->$control_field_name;
              $trigger_value_exist = field_conditional_state_trigger_value_in_field_value($control_values[$lang], $condition['trigger_values'], $condition['condition_type']);
              if (($condition['state'] == 'visible' && !$trigger_value_exist) || ($condition['state'] == 'invisible' && $trigger_value_exist)) {
                $entity->content[$field_name]['#access'] = FALSE;
              }
            }
          }
        }
      }
  }
?>

This was placed on lines 136-155 of field_conditional_state.module. I have not seen any negative effects of the code on my content but please test it out and see if it works.

knretaleato’s picture

I had the same issue on any pages using MediaFront to display nodes even though I did not have conditional states on any of their fields. #2 solved my issue.

Echofive’s picture

I've the same issue too.
I've solved this using the code in the comment #2.

I've created a patch based on this code.

eminencehealthcare’s picture

Patch works for me. Thanks!

Tobias Xy’s picture

Version: 7.x-1.0 » 7.x-1.x-dev
Status: Needs review » Reviewed & tested by the community
FileSize
2.52 KB

I edited patch #4 to match the current dev version. Since there isn't a substantive change of the code, I'll set this issue to RTBC.

Tobias Xy’s picture

Status: Reviewed & tested by the community » Fixed

Committed. :-)

Status: Fixed » Closed (fixed)

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

Anonymous’s picture

Issue summary: View changes

Typo.