Skip to content

Commit

Permalink
Merge pull request #59 from libis/fix/readability_color_handling
Browse files Browse the repository at this point in the history
handle non-existing color
  • Loading branch information
collectiveaccess authored Jan 10, 2023
2 parents f803685 + bb405a6 commit 44ae708
Showing 1 changed file with 19 additions and 3 deletions.
22 changes: 19 additions & 3 deletions app/helpers/htmlFormHelpers.php
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,13 @@ function caHTMLSelect($ps_name, $pa_content, $pa_attributes=null, $pa_options=nu
if (isset($pa_options['contentArrayUsesKeysForValues']) && $pa_options['contentArrayUsesKeysForValues']) {
foreach($pa_content as $vs_val => $vs_opt) {
if ($vb_use_options_for_values) { $vs_val = preg_replace("!^[\s]+!", "", preg_replace("![\s]+$!", "", str_replace(" ", "", $vs_opt))); }
if ($COLOR = ($vs_color = $va_colors[$vs_val]) ? " data-color='#{$vs_color}'" : '') { $vb_uses_color = true; }

$COLOR = "";
if(isset($va_colors[$vs_val])) {
$COLOR = " data-color='#" . $va_colors[$vs_val] . "'";
$vb_uses_color = true;
}

if (is_null($vs_selected_val) || !($SELECTED = (((string)$vs_selected_val === (string)$vs_val) && strlen($vs_selected_val)) ? ' selected="1"' : '')) {
$SELECTED = (is_array($va_selected_vals) && in_array($vs_val, $va_selected_vals)) ? ' selected="1"' : '';
}
Expand All @@ -108,7 +114,12 @@ function caHTMLSelect($ps_name, $pa_content, $pa_attributes=null, $pa_options=nu
} else {
if ($vb_content_is_list) {
foreach($pa_content as $vs_val) {
if ($COLOR = ($vs_color = $va_colors[$vs_val]) ? " data-color='#{$vs_color}'" : '') { $vb_uses_color = true; }

$COLOR = "";
if(isset($va_colors[$vs_val])) {
$COLOR = " data-color='#" . $va_colors[$vs_val] . "'";
$vb_uses_color = true;
}

if (is_null($vs_selected_val) || !($SELECTED = ((string)$vs_selected_val === (string)$vs_val) ? ' selected="1"' : '')) {
$SELECTED = (is_array($va_selected_vals) && in_array($vs_val, $va_selected_vals)) ? ' selected="1"' : '';
Expand All @@ -119,7 +130,12 @@ function caHTMLSelect($ps_name, $pa_content, $pa_attributes=null, $pa_options=nu
} else {
foreach($pa_content as $vs_opt => $vs_val) {
if ($vb_use_options_for_values) { $vs_val = preg_replace("!^[\s]+!", "", preg_replace("![\s]+$!", "", str_replace(" ", "", $vs_opt))); }
if ($COLOR = ($vs_color = $va_colors[$vs_val]) ? " data-color='#{$vs_color}'" : '') { $vb_uses_color = true; }

$COLOR = "";
if(isset($va_colors[$vs_val])) {
$COLOR = " data-color='#" . $va_colors[$vs_val] . "'";
$vb_uses_color = true;
}

if (is_null($vs_selected_val) || !($SELECTED = ((string)$vs_selected_val === (string)$vs_val) ? ' selected="1"' : '')) {
$SELECTED = (is_array($va_selected_vals) && in_array($vs_val, $va_selected_vals)) ? ' selected="1"' : '';
Expand Down

0 comments on commit 44ae708

Please sign in to comment.