Browse Source

Fix bug for the switchable fields

Currently when a field switch to hidden, its required verification
doesn't get purged, this prevents form to be submitted.

Closes-bug: #1708601

Change-Id: I515ff048635f60610260ddfc076030e58724bf29
(cherry picked from commit 678bb64324)
jiangpch 1 year ago
parent
commit
d8277a49cb
1 changed files with 9 additions and 0 deletions
  1. 9
    0
      horizon/static/horizon/js/horizon.forms.js

+ 9
- 0
horizon/static/horizon/js/horizon.forms.js View File

@@ -507,12 +507,21 @@ horizon.addInitFunction(horizon.forms.init = function () {
507 507
 
508 508
         if (typeof data === "undefined" || !visible) {
509 509
           $input.closest('.form-group').hide();
510
+          //The required verification should be removed and recorded
511
+          if ($input.attr('required') === 'required') {
512
+            $input.data('savedRequired', 'required');
513
+            $input.removeAttr('required');
514
+          }
510 515
         } else {
511 516
           //If the input is a checkbox no need to replace html for label since it has another structure
512 517
           if($input.attr('type') !== "checkbox"){
513 518
             $('label[for=' + $input.attr('id') + ']').html(data);
514 519
           }
515 520
           $input.closest('.form-group').show();
521
+          //Add the required verification if it is required
522
+          if ($input.data('savedRequired') === 'required') {
523
+            $input.attr("required", "required");
524
+          }
516 525
         }
517 526
       }
518 527
 

Loading…
Cancel
Save