Hide Forgot
Description of problem: If I follow the instructions in the documentation for making a dynamic dialog and making it a required field, the dialog does not require that a selection is made on the dialog when clicking submit. Version-Release number of selected component (if applicable): CloudForms 5.6.2.2.20161017185613_7cee0a0 How reproducible: For every dynamic dialog that is a dropdown. Steps to Reproduce: 1. 2. 3. Actual results: Expected results: The expected behavior is that when clicking submit, that the dialog is refreshed with error boxes indicating that the field must be filled out/selected. Additional info:
The way the documentation is written currently, there is no reason that the "required" error message should show up, since the drop-down is already pre-selected with a value. Even if you left off the default value part, it should still be pre-selected with the first value. The only way that you will see the "required" error dialog is if you make one of the values nil, for example: $evm.object["values"] = {nil => "Nothing selected", "A" => "A", "B" => "B"} Then, as long as you aren't setting a default value, the "Nothing selected" should be the first value and when you hit submit, you should see the "required" error message.
Well, the problem in this case is that the automate method hasn't run yet, which is what is setting the dialog field to "required" in the first place. It sounds like the dialog field needs to be tweaked to show the refresh button, load values on init, and then change the automate method to look at the other field that this drop down is "dependent" on, and not give correct values back until that field is filled out. Then if that field isn't filled out, you should still get the error that it is required.
I believe this is the same customer in this talk topic: http://talk.manageiq.org/t/making-dynamic-dropdowns-required/1913/2. I think we can close this as it's apparent what happened. I think the best course of action is if the customer is concerned about performance due to the "load values on init", that the automate method has a short circuit "if" block so that the potentially expensive calculation isn't run unless whichever other field they're relying on is filled out. Something like this, maybe: dialog_field = $evm.object other_dialog_field = $evm.root.attributes["other_dialog_field"] dialog_field["required"] = true if other_dialog_field == "example" dialog_field["values"] = {nil => "Select something from other dialog field first!"} else # expensive calculation for the values dialog_field["values"] = values end