Closed (won't fix)
Project:
Profile 2
Version:
7.x-1.x-dev
Component:
Code
Priority:
Normal
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
9 Apr 2013 at 21:43 UTC
Updated:
20 Jun 2013 at 06:54 UTC
When rendering a profile boolean fields render even when their value is set to false. This can create a degraded user experience because the profile typically has a label and "0" or "" for the value when false. Is there any way to have profile2 hide boolean fields set to false?
Comments
Comment #1
anil_89 commentedIssue for check permission need to change it check condition
if (in_array(FALSE, $access, TRUE)) {
function profile2_access($op, $profile = NULL, $account = NULL) {
if (user_access('administer profiles', $account)) {
return TRUE;
}
if ($op == 'create' || $op == 'update') {
$op = 'edit';
}
// Allow modules to grant / deny access.
$access = module_invoke_all('profile2_access', $op, $profile, $account);
///echo "
"; print_R($access);exit; // Only grant access if at least one module granted access and no one denied // access. if (in_array(FALSE, $access, TRUE)) { return FALSE; } elseif (in_array(TRUE, $access, TRUE)) { return TRUE; } return FALSE; }Comment #2
anil_89 commentedreplace with
if (in_array(FALSE, $access, TRUE)) {
return FALSE;
}
elseif (in_array(TRUE, $access, TRUE)) {
return TRUE;
}
foreach($access as $value){
if($value == 1){
return true;
}
}
return FALSE;
on profile2.module file
Comment #3
anil_89 commentedalso can you use
function profile2_access($op, $profile = NULL, $account = NULL) {
if (user_access('administer profiles', $account)) {
return TRUE;
}
if ($op == 'create' || $op == 'update') {
$op = 'edit';
}
// Allow modules to grant / deny access.
$access = module_invoke_all('profile2_access', $op, $profile, $account);
// patch for permission
foreach($access as $key_module => $value){
if($value ==0 && $value!=''){
return false;
}
}
return true;
}
Comment #4
hongpong commentedIs there a solution to hide booleans when they are false without patching this? Or possibly creating some new field in display suite config to indicate displays for true/false? Basically I just need this hidden for false values.
Comment #5
joachim commented@anil_89 please don't recommend people hack modules, *especially* when there is a hook invocation right there in the code you are hacking!
Secondly, that function is to do with access to the entire profile. The OP appears to be about single fields.
Surely these render the same anywhere -- a boolean field on a node would have the same problem.
Therefore, this isn't something that Profile2 can or should fix.