Browse Source

Show an asterisk mark for 'switched' conditional filed(required=Flase)

Change-Id: I80dbd4b6aa9f3adeaf508b05f878b9f11cacf80a
Partial-Bug: #1755131
tags/14.0.0.0b1
wangliangyu 1 year ago
parent
commit
0efbb377a5

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

@@ -523,6 +523,11 @@ horizon.addInitFunction(horizon.forms.init = function () {
523 523
             $input.attr("required", "required");
524 524
           }
525 525
         }
526
+        if ($input.data("required-when-shown") === true &&
527
+            $input.closest('.form-group').find('.hz-icon-required').length < 1) {
528
+          var asterist_text = '<span class="hz-icon-required fa fa-asterisk"></span>';
529
+          $input.closest('.form-group').children('.control-label').after(asterist_text);
530
+        }
526 531
       }
527 532
 
528 533
       $fieldset.find('.switched[data-switch-on*="' + slug + '"]').each(handle_switched_field);

+ 1
- 0
openstack_dashboard/dashboards/project/instances/forms.py View File

@@ -307,6 +307,7 @@ class AttachInterface(forms.SelfHandlingForm):
307 307
         required=False,
308 308
         widget=forms.ThemableSelectWidget(attrs={
309 309
             'class': 'switched',
310
+            'data-required-when-shown': 'true',
310 311
             'data-switch-on': 'specification_method',
311 312
             'data-specification_method-network': _('Network'),
312 313
         }))

Loading…
Cancel
Save