Commit 68cd04b 1 parent 1738ca0 commit 68cd04b Copy full SHA for 68cd04b
File tree 1 file changed +7
-5
lines changed
libreforms_fastapi/app/templates
1 file changed +7
-5
lines changed Original file line number Diff line number Diff line change @@ -57,23 +57,25 @@ $(document).ready(function() {
57
57
// Populate form fields with fetched data
58
58
function populateFormData (response ) {
59
59
const data = response .data ;
60
+
61
+ console .log (data);
62
+
60
63
for (const key in data) {
61
64
const value = data[key];
62
65
const field = $ (` [name="${ key} "]` );
63
66
64
67
if (Array .isArray (value)) {
65
68
// For checkboxes or multi-selects
66
69
value .forEach (val => {
67
- const escapedValue = val .replace (/ \. / g , ' \\ .' );
68
- $ (` [name="${ key} "]` ).filter (` [value="${ escapedValue} "]` ).prop (' checked' , true );
70
+ $ (` [name="${ key} "]` ).filter (` [value="${ val} "]` ).prop (' checked' , true );
69
71
});
70
72
} else if (typeof value === ' object' && value !== null ) {
71
- // Handle objects (though you mentioned these are rare)
73
+ // I'm leaving this hear but I don't think we are going to have too many of these
72
74
} else {
73
75
// Handle strings and numbers
74
76
if (field .is (' :radio' )) {
75
- const escapedValue = value . replace ( / \. / g , ' \\ . ' );
76
- field .filter (` [value="${ escapedValue } "]` ).prop (' checked' , true );
77
+ // If the field is a radio button, find the one that matches the value and check it
78
+ field .filter (` [value="${ value } "]` ).prop (' checked' , true );
77
79
} else {
78
80
// For all other field types, just set the value
79
81
field .val (value);
You can’t perform that action at this time.
0 commit comments