Dropdownlists: Validator triggering even though a selection has been made

2 Answers 49 Views
DropDownList
Lee
Top achievements
Rank 1
Iron
Lee asked on 05 Dec 2023, 08:16 AM

Hi,  I've created a drop-down list for my react application. However, when I set the initial value, the required validator is triggering even though a selection has been made. Is there something else I need to be doing?

<Field
name={'site'}
component={FormDropDownList}
textField="title"
dataItemKey="id"
data={sites}
// label={'Select the site you are attending.'}
defaultItem={sitesReducer.nearestSite ? sitesReducer.nearestSite : {
title: 'Select...',
}}
validator={requiredValidator}
/>

2 Answers, 1 is accepted

Sort by
0
Accepted
Lee
Top achievements
Rank 1
Iron
answered on 03 Mar 2024, 08:57 PM

Hi,

just an update. I've managed to solve the issue by adding this to my Form. "ignoreModified={true}"

<Form onSubmit={handleSubmit} ignoreModified={true} initialValues={{

site: nearestSite ? nearestSite : {
title: 'Select Site',
}
}}
0
Filip
Telerik team
answered on 06 Dec 2023, 07:10 PM

Hello, Lee,

I inspected the provided code, however I did not find anything that could be causing this unwanted behavior.  More information on how to use a DropDownList with validation can be found in the following article:

https://www.telerik.com/kendo-react-ui/components/dropdowns/dropdownlist/forms/#toc-setting-validation-requirements

In case you have already reviewed it and the issue persists, can you please send us a runnable example that reproduces the issue? This will enable me to debug it locally and see what might be causing  it and find a suitable solution.

Regards,
Filip
Progress Telerik

Stay tuned by visiting our public roadmap and feedback portal pages! Or perhaps, if you are new to our Kendo family, check out our getting started resources!

Tags
DropDownList
Asked by
Lee
Top achievements
Rank 1
Iron
Answers by
Lee
Top achievements
Rank 1
Iron
Filip
Telerik team
Share this question
or