Bug 1396668 - Can not make dynamic dialog drop downs required
Summary: Can not make dynamic dialog drop downs required
Keywords:
Status: CLOSED WONTFIX
Alias: None
Product: Red Hat CloudForms Management Engine
Classification: Red Hat
Component: Automate
Version: 5.6.0
Hardware: Unspecified
OS: Unspecified
high
high
Target Milestone: GA
: cfme-future
Assignee: eclarizi
QA Contact: Shveta
URL:
Whiteboard: service:dialog
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2016-11-18 22:39 UTC by myoder
Modified: 2019-12-16 07:24 UTC (History)
5 users (show)

Fixed In Version:
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed: 2016-11-30 15:29:09 UTC
Category: Bug
Cloudforms Team: ---
Target Upstream Version:


Attachments (Terms of Use)

Description myoder 2016-11-18 22:39:44 UTC
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:

Comment 5 eclarizi 2016-11-22 21:03:55 UTC
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.

Comment 8 eclarizi 2016-11-23 15:52:00 UTC
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.

Comment 9 eclarizi 2016-11-30 15:29:09 UTC
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


Note You need to log in before you can comment on or make changes to this bug.