I have a profile2 profile with several boolean fields using a checkbox to set them. Unchecked values are never causing pcp to be considered incomplete. This is because the field values returned are:

  [field_antiharassment] => Array
        (
            [und] => Array
                (
                    [0] => Array
                        (
                            [value] => 
                        )

                )

        )

in pcp_get_user_profile_values the following is being done:

foreach ($fields as $field_name => $field_values) {
        if (isset($profile->$field_name) && $field = $profile->$field_name) {
           $fiid = $field_values['id'];
           $user_fields[$field_name] = $field['und'][0];
       }
    }

since $field['und'][0] is set, we add the field to user_fields.

I worked around this by extending the check to see if $field['und'][0] has any values as follows:

foreach ($fields as $field_name => $field_values) {
        if (isset($profile->$field_name) && $field = $profile->$field_name) {
            foreach ($field['und'][0] as $value) {
                if (!is_null($value)) {
                    $fiid = $field_values['id'];
                    $user_fields[$field_name] = $field['und'][0];
                    break;
                }
            }
        }
    }

I've attached a patch for your consideration.

Comments

StevenWill’s picture

StatusFileSize
new287.69 KB

I posted a patch in comment 1 by mistake. Please delete this patch.

perennial.sky’s picture

Status: Active » Closed (duplicate)
bkat’s picture

The issue you marked it a duplicate of is for Drupal 6 and this one and the patch is for Drupal 7.

bkat’s picture

BarisW’s picture

Status: Closed (duplicate) » Fixed

Thanks bkat for the fix. I've committed it.

BarisW’s picture

Version: 7.x-1.6 » 7.x-1.x-dev

  • BarisW committed 6193fd3 on 7.x-1.x
    Remove wrongly committed Context code at issue #2206201
    

Status: Fixed » Closed (fixed)

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