Skip to content

Commit e5cc24b

Browse files
committed
Show value is there is no label
1 parent f65d4af commit e5cc24b

File tree

1 file changed

+16
-13
lines changed

1 file changed

+16
-13
lines changed

helper.php

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ function db_field_replace($before_str, $user_id,$rules,$fields,$search_paramtofi
7272
}
7373

7474
//Fieldtypes with a label name in the comprofiler_field_values
75+
// normal checkbox currently returns a 0 or 1
7576
if ( !empty($datatoinsert) and ($fieldtype=='multicheckbox' or $fieldtype=='multiselect' or $fieldtype=='select' or $fieldtype=='radio')) {
7677

7778

@@ -88,17 +89,21 @@ function db_field_replace($before_str, $user_id,$rules,$fields,$search_paramtofi
8889
$dblabel->setQuery($query);
8990
$labels = $dblabel->loadAssoc();
9091

91-
foreach ($labels as $label) {
92-
$datatoinsert .= $label. " " ;
92+
foreach ($labels as $label) {
93+
if(empty($label)) {
94+
$datatoinsert .= $value. " " ;
95+
}
96+
else{
97+
$datatoinsert .= $label. " " ;
98+
}
9399
}
94-
95100

96101
}
97102

98-
}
99-
103+
}
100104

101-
// normal checkbox currently returns a 0 or 1
105+
106+
102107

103108
//check if there is a rule for this field
104109
if (null !==(array_search($fieldtouse,array_column($rules,'tag_name'))) ) {
@@ -109,13 +114,11 @@ function db_field_replace($before_str, $user_id,$rules,$fields,$search_paramtofi
109114
// If the rule is found:
110115
if (strtolower($rule['tag_name']) == $fieldtouse) {
111116

112-
// check if show still true and data is not empty or that it is a custom tag created in the module.
113-
if ($show == 'yes' and ((!empty($datatoinsert)) or $field['type']=='custom') ) {
114-
$datatoinsert = str_ireplace($paramtofind, $datatoinsert, $rule['htmlcode']);
115-
117+
// check if show still true and data is not empty or that it is a custom tag created in the module.
118+
if ($show == 'yes' and ((!empty($datatoinsert)) or $fieldtype=='custom') ) {
119+
$datatoinsert = str_ireplace($paramtofind, $datatoinsert, $rule['htmlcode']);
116120
} else {
117-
$datatoinsert = str_ireplace($paramtofind, $datatoinsert, $rule['htmlcode_no']);
118-
121+
$datatoinsert = str_ireplace($paramtofind, $datatoinsert, $rule['htmlcode_no']);
119122
}
120123
}
121124
}
@@ -171,7 +174,7 @@ public static function getData( $params )
171174
// add additional names created in the parameters
172175
$query .= $additional_names ;
173176
// retrieve fields from type images as first. this way other tags in the htmlcode then from the image will also be replaced without additional while loop
174-
$query .= " order by FIELD(type,'datetime','image') desc";
177+
$query .= " order by FIELD(type,'image') desc";
175178
$db->setQuery($query);
176179
$fields = $db->loadAssocList();
177180

0 commit comments

Comments
 (0)