Update on checkboxes
authorSteve Sutton <steve@gaslightmedia.com>
Mon, 11 Jan 2016 13:13:41 +0000 (08:13 -0500)
committerSteve Sutton <steve@gaslightmedia.com>
Mon, 11 Jan 2016 13:13:41 +0000 (08:13 -0500)
controllers/front.php

index 2d27335..3221ed7 100644 (file)
@@ -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']] == ''