Location Input
Collect a country and state/region pair.
Preview
If your country has states, it will be appear after selecting country
Usage
<FormFieldcontrol={form.control}name="select_country"render={({ field }) => (<FormItem><FormLabel>Select Country</FormLabel><FormControl><LocationSelectoronCountryChange={(country) => {const currentValue = form.getValues(field.name)const currentState =Array.isArray(currentValue) && typeof currentValue[1] === "string"? currentValue[1]: ""form.setValue(field.name, [country?.name || '', currentState], {shouldValidate: true,shouldDirty: true,shouldTouch: true})}}onStateChange={(state) => {const currentValue = form.getValues(field.name)const currentCountry =Array.isArray(currentValue) && typeof currentValue[0] === "string"? currentValue[0]: ''form.setValue(field.name, [currentCountry, state?.name || ''], {shouldValidate: true,shouldDirty: true,shouldTouch: true})}}/></FormControl><FormDescription>If your country has states, it will be appear after selecting country</FormDescription><FormMessage /></FormItem>)}/>
Details
This field expects a selector backed by country and state datasets.
Component referenceform-builder/components/ui/location-input.tsx