Simplify state handling for station profiles

Refactored PHP model to always use 'station_state' from the form, removing special handling for Canadian states. Updated JS to clear hidden state dropdowns on form submission, ensuring only the visible state's value is submitted.
这个提交包含在:
Peter Goodhall 2025-08-02 11:26:00 +01:00
父节点 01b24e095e
当前提交 33ec51d7d5
共有 2 个文件被更改,包括 21 次插入18 次删除

查看文件

@ -75,12 +75,8 @@ class Stations extends CI_Model {
$station_active = 1; $station_active = 1;
} }
// Check if the state is Canada and get the correct state // Get the state value from the form
if ($this->input->post('dxcc') == 1 && $this->input->post('station_ca_state') !="") { $state = xss_clean($this->input->post('station_state', true));
$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 // Create data array with field values
$data = array( $data = array(
@ -129,16 +125,10 @@ class Stations extends CI_Model {
function edit() { function edit() {
// Check if the state is Canada and get the correct state // Get the state value from the form
if ($this->input->post('dxcc') == 1 && $this->input->post('station_ca_state') !="") { $state = xss_clean($this->input->post('station_state', true));
$state = xss_clean($this->input->post('station_ca_state', true));
} else { log_message('error', 'State value: ' . $state);
$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( $data = array(
'station_profile_name' => xss_clean($this->input->post('station_profile_name', true)), 'station_profile_name' => xss_clean($this->input->post('station_profile_name', true)),

查看文件

@ -45,7 +45,8 @@ $(document).ready( function () {
}; };
// Hide all states initially // 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. * Gets the selected DXCC ID and shows the corresponding state.
*/ */
@ -69,9 +70,21 @@ $(document).ready( function () {
var stateToShow = stateMap[selectedValue] || stateMap['default']; var stateToShow = stateMap[selectedValue] || stateMap['default'];
// Hide all states // 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 // Show the selected state
$("#" + stateToShow).show(); $("#" + 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('');
}
});
});
} ); } );