@@ -158,25 +158,29 @@ export class GlpiFormRendererController
158
158
Object . values ( response . errors ) . forEach ( error => {
159
159
// Highlight the field with error
160
160
const question = $ ( `[data-glpi-form-renderer-id="${ error . question_id } "][data-glpi-form-renderer-question]` ) ;
161
- if ( question . length ) {
162
- // Find the input field within the question
163
- const inputField = question . find ( 'input:not([data-uploader-name]), select, textarea' ) ;
164
- if ( inputField . length ) {
165
- // Generate a unique ID for the error message
166
- const errorId = `error-${ error . question_id } ` ;
167
-
168
- // Add validation classes and accessibility attributes
169
- inputField
170
- . addClass ( 'is-invalid' )
171
- . attr ( 'aria-invalid' , 'true' )
172
- . attr ( 'aria-errormessage' , errorId ) ;
173
-
174
- // Add a tooltip with the error message
175
- inputField . parent ( ) . append (
176
- `<span id="${ errorId } " class="invalid-tooltip">${ error . message } </span>`
177
- ) ;
178
- }
161
+ if ( ! question . length ) {
162
+ return ;
179
163
}
164
+
165
+ // Find the input field within the question
166
+ const inputField = question . find ( 'input:not([data-uploader-name]), select, textarea' ) ;
167
+ if ( ! inputField . length ) {
168
+ return ;
169
+ }
170
+
171
+ // Generate a unique ID for the error message
172
+ const errorId = `error-${ error . question_id } ` ;
173
+
174
+ // Add validation classes and accessibility attributes
175
+ inputField
176
+ . addClass ( 'is-invalid' )
177
+ . attr ( 'aria-invalid' , 'true' )
178
+ . attr ( 'aria-errormessage' , errorId ) ;
179
+
180
+ // Add a tooltip with the error message
181
+ inputField . parent ( ) . append (
182
+ `<span id="${ errorId } " class="invalid-tooltip">${ error . message } </span>`
183
+ ) ;
180
184
} ) ;
181
185
182
186
return false ;
0 commit comments