You are here

public static function EntityCompleteProfileController::hasEmptyRequiredFields in Complete profile 7

1 call to EntityCompleteProfileController::hasEmptyRequiredFields()
UserCompleteProfileController::hasEmptyRequiredFields in includes/UserCompleteProfileController.php

File

includes/EntityCompleteProfileController.php, line 16

Class

EntityCompleteProfileController

Code

public static function hasEmptyRequiredFields($entity_type, $entity) {
  list(, , $bundle) = entity_extract_ids($entity_type, $entity);
  $instances = field_info_instances($entity_type, $bundle);
  foreach ($instances as $instance) {

    // Only check required fields.
    if (!empty($instance['required'])) {

      // Check if the required field is empty.
      $field = field_info_field($instance['field_name']);
      if (self::isFieldEmpty($entity_type, $entity, $field)) {

        // Check that the user can actually edit their missing field.
        if (field_access('edit', $field, $entity_type, $entity)) {
          return TRUE;
        }
      }
    }
  }
}