From 370daa3e55439b156652bce44760cece929d9f84 Mon Sep 17 00:00:00 2001 From: Peter Goodhall Date: Sat, 2 Aug 2025 11:27:41 +0100 Subject: [PATCH] Revert "Simplify state handling for station profiles" This reverts commit 33ec51d7d526743f98b6a372557357a7ac6baac3. --- application/models/Stations.php | 22 ++++++++++++++++------ assets/js/sections/station_locations.js | 17 ++--------------- 2 files changed, 18 insertions(+), 21 deletions(-) diff --git a/application/models/Stations.php b/application/models/Stations.php index fca74f7c..f1447b9a 100644 --- a/application/models/Stations.php +++ b/application/models/Stations.php @@ -75,8 +75,12 @@ class Stations extends CI_Model { $station_active = 1; } - // Get the state value from the form - $state = xss_clean($this->input->post('station_state', true)); + // Check if the state is Canada and get the correct state + if ($this->input->post('dxcc') == 1 && $this->input->post('station_ca_state') !="") { + $state = xss_clean($this->input->post('station_ca_state', true)); + } else { + $state = xss_clean($this->input->post('station_state', true)); + } // Create data array with field values $data = array( @@ -125,10 +129,16 @@ class Stations extends CI_Model { function edit() { - // Get the state value from the form - $state = xss_clean($this->input->post('station_state', true)); - - log_message('error', 'State value: ' . $state); + // Check if the state is Canada and get the correct state + if ($this->input->post('dxcc') == 1 && $this->input->post('station_ca_state') !="") { + $state = xss_clean($this->input->post('station_ca_state', true)); + } else { + $state = xss_clean($this->input->post('station_state', true)); + // log as an error the value of state + log_message('error', 'State value: ' . $state); + } + + log_message('error', 'State value: ' . $this->input->post('station_state', true)); $data = array( 'station_profile_name' => xss_clean($this->input->post('station_profile_name', true)), diff --git a/assets/js/sections/station_locations.js b/assets/js/sections/station_locations.js index fb731f7f..8568a096 100644 --- a/assets/js/sections/station_locations.js +++ b/assets/js/sections/station_locations.js @@ -45,8 +45,7 @@ $(document).ready( function () { }; // Hide all states initially - $("#canada_state, #aland_state, #asiatic_russia_state, #belarus_state, #mexico_state, #eu_russia_state, #argentina_state, #brazil_state, #chile_state, #us_state, #paraguay_state, #korea_state, #uruguay_state, #venezuela_state, #australia_state, #png_state, #nz_state, #belgium_state, #italy_state, #netherlands_state").hide(); - + $("#canada_state, #aland_state, #asiatic_russia_state, #belarus_state, #mexico_state, #eu_russia_state, #argentina_state, #brazil_state, #chile_state, #us_state, #paraguay_state, #korea_state, #uruguay_state, #venezuela_state, #australia_state, #png_state, #nz_state, #belgium_state, #italy_state, #netherlands_state").hide(); /** * Gets the selected DXCC ID and shows the corresponding state. */ @@ -70,21 +69,9 @@ $(document).ready( function () { var stateToShow = stateMap[selectedValue] || stateMap['default']; // Hide all states - $("#mexico_state, #belarus_state, #asiatic_russia_state, #aland_state, #canada_state, #us_state, #eu_russia_state, #argentina_state, #brazil_state, #chile_state, #paraguay_state, #korea_state, #uruguay_state, #venezuela_state, #australia_state, #png_state, #nz_state, #belgium_state, #italy_state, #netherlands_state").hide(); + $("#mexico_state, #belarus_state, #asiatic_russia_state, #aland_state, #canada_state, #us_state, #eu_russia_state, #argentina_state, #brazil_state, #chile_state, #paraguay_state, #korea_state, #uruguay_state, #venezuela_state, #australia_state, #png_state, #nz_state, #belgium_state, #italy_state, #netherlands_state").hide(); // Show the selected state $("#" + stateToShow).show(); }); - - /** - * Form submission handler to ensure only visible state value is submitted - */ - $('form[name="create_profile"]').on('submit', function() { - // Clear all hidden state dropdown values before submission - $("#mexico_state, #belarus_state, #asiatic_russia_state, #aland_state, #canada_state, #us_state, #eu_russia_state, #argentina_state, #brazil_state, #chile_state, #paraguay_state, #korea_state, #uruguay_state, #venezuela_state, #australia_state, #png_state, #nz_state, #belgium_state, #italy_state, #netherlands_state").each(function() { - if ($(this).is(':hidden')) { - $(this).find('select[name="station_state"]').val(''); - } - }); - }); } );