I have a DropDownChoice component on my Form and when the form is submitted and nothing is selected from the DropDownChoice, the default value that’s returned is “-1”. Is there are a way to change this behavior?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
This behavior is controlled by a constant field
in
AbstractSingleSelectChoice, which is a superclass ofDropDownChoice.You can’t change this value in a subclass, so in order to change the value used, you would have to locate uses of this constant and override the methods that use it to use some other default.
Doing that would be risky, though it’s likely possible. I know you’d have to override at least
getDefaultChoice(final Object selected)andgetModelValue().Why do you wish to do this? It’s a sensible value for its purpose.
Perhaps there’s a better approach to accomplishing your underlying need.