From ed3b76d2178830b634e8065c40d7bfdd1e13f0e0 Mon Sep 17 00:00:00 2001 From: Steve Sutton Date: Mon, 11 Jan 2016 08:13:41 -0500 Subject: [PATCH] Update on checkboxes --- controllers/front.php | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/controllers/front.php b/controllers/front.php index 2d27335..3221ed7 100644 --- a/controllers/front.php +++ b/controllers/front.php @@ -337,20 +337,28 @@ class glm_employment_front if (in_array($field['name'], array('fname', 'lname', 'mname'))) { $this->$field['name'] = $form[$rowKey][$fieldKey]['value']; } - if ( ($field['type'] == 'checkbox' || $field['type'] == 'radio') - && isset($field['opts']) && !empty($field['opts']) + if ( ($field['type'] == 'radio') && isset($field['opts']) && !empty($field['opts']) ) { foreach ($field['opts'] as $opKey => $option) { if (isset($_POST[$field['name']])) { $form[$rowKey][$fieldKey]['opts'][$opKey]['checked'] = true; - if ($field['type'] == 'checkbox') { - $_POST[$option['name']] = $option['value']; - } - } } } + if ( ($field['type'] == 'checkbox') && isset($field['opts']) && !empty($field['opts']) + ) { + $checkboxOptions = array(); + foreach ($field['opts'] as $opKey => $option) { + if (isset($_POST[$option['name']])) { + $form[$rowKey][$fieldKey]['opts'][$opKey]['checked'] = true; + $_POST[$option['name']][] = $option['value']; + $checkboxOptions[] = $option['value']; + } + } + $form[$rowKey][$fieldKey]['value'][] = implode(', ', $checkboxOptions); + $checkboxOptions = array(); + } if ( isset($field['req']) && $field['req'] == true && $_POST[$field['name']] == '' -- 2.17.1