From 8cfb767016966bde77cbfba82f16bfdea6e51921 Mon Sep 17 00:00:00 2001 From: Steve Sutton Date: Thu, 18 Dec 2014 15:05:45 -0500 Subject: [PATCH] Issue with the radio buttons Fix issue with the radio buttons not being checked if they are set as required. --- controllers/front.php | 15 +++++++++------ views/front/formTemplate.php | 8 +++++--- 2 files changed, 14 insertions(+), 9 deletions(-) diff --git a/controllers/front.php b/controllers/front.php index 3307d4e..622fa68 100644 --- a/controllers/front.php +++ b/controllers/front.php @@ -319,6 +319,7 @@ class glm_employment_front public function form_process($part) { $this->clean_post(); + $form = $this->load_form_settings($part); if ($jobId = filter_var($_REQUEST['job'], FILTER_VALIDATE_INT)) { $this->job = $jobId; @@ -336,14 +337,17 @@ class glm_employment_front if (in_array($field['name'], array('fname', 'lname', 'mname'))) { $this->$field['name'] = $form[$rowKey][$fieldKey]['value']; } - if ( $field['type'] == 'checkbox' - && isset($field['opts']) - && !empty($field['opts']) + if ( ($field['type'] == 'checkbox' || $field['type'] == 'radio') + && isset($field['opts']) && !empty($field['opts']) ) { + foreach ($field['opts'] as $opKey => $option) { - if (isset($_POST[$option['name']])) { + if (isset($_POST[$field['name']])) { $form[$rowKey][$fieldKey]['opts'][$opKey]['checked'] = true; - $_POST[$option['name']] = $option['value']; + if ($field['type'] == 'checkbox') { + $_POST[$option['name']] = $option['value']; + } + } } } @@ -351,7 +355,6 @@ class glm_employment_front && $field['req'] == true && $_POST[$field['name']] == '' && (isset($field['type'])) - && $field['type'] != 'radio' ) { $form[$rowKey][$fieldKey]['error'] = $field['label'] . ' is required!'; ++$this->errorCount; diff --git a/views/front/formTemplate.php b/views/front/formTemplate.php index 80452a4..9c2bee1 100644 --- a/views/front/formTemplate.php +++ b/views/front/formTemplate.php @@ -95,15 +95,17 @@ - + pattern="" id="" name="" type="radio" - value="" - " + /> -- 2.17.1