fix(07-01): fix job type dropdown not pre-populating on edit

Improved JavaScript to use case-insensitive matching for select fields, so 'vollzeit' matches 'Vollzeit'. Also normalized all job_type values to lowercase when saving to ensure consistency.

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
2026-01-17 21:27:49 +09:00
parent 9142b56a9f
commit 0c9ebb9e89
2 changed files with 19 additions and 2 deletions

View File

@@ -619,7 +619,7 @@ class DDHH_JM_Formidable {
break; break;
case 'job_type': case 'job_type':
case 'job_type2': case 'job_type2':
$job_type = sanitize_text_field( $value ); $job_type = strtolower( sanitize_text_field( $value ) );
break; break;
case 'job_deadline': case 'job_deadline':
case 'job_deadline2': case 'job_deadline2':

View File

@@ -98,13 +98,30 @@ if ( $is_edit_mode ) {
if (field.length) { if (field.length) {
if (field.is('select')) { if (field.is('select')) {
field.val(value).trigger('change'); // For select fields, try case-insensitive matching
var options = field.find('option');
var matched = false;
options.each(function() {
if ($(this).val().toLowerCase() === value.toLowerCase()) {
field.val($(this).val()).trigger('change');
matched = true;
console.log('Matched select option:', $(this).val(), 'for value:', value);
return false; // break
}
});
if (!matched) {
console.warn('No matching option found for field', fieldId, 'value:', value, 'Available options:', options.map(function() { return $(this).val(); }).get());
}
} else if (field.is(':checkbox') || field.is(':radio')) { } else if (field.is(':checkbox') || field.is(':radio')) {
field.filter('[value="' + value + '"]').prop('checked', true); field.filter('[value="' + value + '"]').prop('checked', true);
} else { } else {
field.val(value); field.val(value);
} }
console.log('Populated field ' + fieldId + ' with:', value); console.log('Populated field ' + fieldId + ' with:', value);
} else {
console.warn('Field not found:', fieldId);
} }
}); });
}, 500); }, 500);