I have a Select Box that is populated dynamically and has the mandatory flag set.
In certain cases no data is returned from the database and as such the user has no values to select.
In this case I would expect the user to not be able to continue as the mandatory flag should stop the validation from continuing but it does not and the warning triangle does not appear either.
I have tried creating a blank fragment but the validation is still not working.
Is there a different way this can be validated?
In the meantime I'll hide the button that calls the validation within the controller if there is no data in the drop down which will prevent the user from continuing.
In certain cases no data is returned from the database and as such the user has no values to select.
In this case I would expect the user to not be able to continue as the mandatory flag should stop the validation from continuing but it does not and the warning triangle does not appear either.
I have tried creating a blank fragment but the validation is still not working.
Is there a different way this can be validated?
In the meantime I'll hide the button that calls the validation within the controller if there is no data in the drop down which will prevent the user from continuing.
RE: Validation Failure on unpopulated Select Box
There is a problem with the validation of select boxes when they do not contain any entries. Where as this should cause a validation error if the select box is mandatory, it instead leads to a JavaScript error. (This problem has been resolved in v4)
To work around this you should be able to create a 'blank' entry record with a controller rule in the situation that no data has been found from the database.
For example, assume your select box is bound to information within the Data block of the form:
<select_data> <record> <value>1</value> <text>one</text> </record> <record> <value>2</value> <text>two</text> </record> <record> <value>3</value> <text>three</text> </record> </select_data>
You could then add a rule to insert a blank structure if the actual data is not present. eg
As the value element is blank, this entry will not be treated as a valid value by the client side validation, and so should cause the mandatory error to appear.
You mention that you tried creating a blank fragment. Was this the type of approach you tried? What problems did you have with this?
Regards,
Gerard