Dropdown Error :: Pick value from the Dropdown

Silverstripe Version: 4.11

Question: Error :: Value not present in DropDown box

Hi there,

I have two dropdowns A and B. Dropdown B’s values are populated based on what is selected in A via JS.
Problem is once I submit the form I am getting an error saying “Please pick the values from the Dropdown list”. I know why I am getting this. The options in Dropdown B is populated by JS and they are initially not present when the page loads.

Wondering if there is a way for me to overcome this in Silverstripe?


I’m afraid without any code, this is going to be virtually impossible to diagnose.

Is this a front-end form, or are you doing something in the CMS?
What form validation is being used? Is there JS validation, backend validation?
Is the error message being generated from the backend, or in JS?
Where is the data coming from?
Where is the data going?
What javascript is being used?
How is the form built?

So many things this could be… you’ll need to help narrow it down.

The error you’re encountering comes from the validate() method in SingleSelectField, which DropdownField is a subclass of. It’s there to prevent malicious actors from sending values that aren’t valid.

In this case, you’ll most likely need to implement a subclass of DropdownField either avoiding that validation, or providing the source values to the PHP context based on the value of the dropdown A.