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:
@@ -619,7 +619,7 @@ class DDHH_JM_Formidable {
|
||||
break;
|
||||
case 'job_type':
|
||||
case 'job_type2':
|
||||
$job_type = sanitize_text_field( $value );
|
||||
$job_type = strtolower( sanitize_text_field( $value ) );
|
||||
break;
|
||||
case 'job_deadline':
|
||||
case 'job_deadline2':
|
||||
|
||||
@@ -98,13 +98,30 @@ if ( $is_edit_mode ) {
|
||||
|
||||
if (field.length) {
|
||||
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')) {
|
||||
field.filter('[value="' + value + '"]').prop('checked', true);
|
||||
} else {
|
||||
field.val(value);
|
||||
}
|
||||
console.log('Populated field ' + fieldId + ' with:', value);
|
||||
} else {
|
||||
console.warn('Field not found:', fieldId);
|
||||
}
|
||||
});
|
||||
}, 500);
|
||||
|
||||
Reference in New Issue
Block a user