CountryFieldBuilderFor renders the GDF country list through SelectFieldBuilder, with a shortcut button that selects the country detected from the browser request.

Presentation Styles And Alerts

Country

Required field
C#
@model DMBFormBuilderLabs.Models.FormBuilderCountryExampleModel

@Html.CountryFieldBuilderFor(m => m.Country).Render()

Floating country

C#
@model DMBFormBuilderLabs.Models.FormBuilderCountryExampleModel

@Html.CountryFieldBuilderFor(m => m.FloatingCountry).SetLabelPresentation(FormLabelPresentation.Floating).Render()

Inline country

C#
@model DMBFormBuilderLabs.Models.FormBuilderCountryExampleModel

@Html.CountryFieldBuilderFor(m => m.InlineCountry).SetLabelPresentation(FormLabelPresentation.Inline).Render()

Grouped country

C#
@model DMBFormBuilderLabs.Models.FormBuilderCountryExampleModel

@Html.CountryFieldBuilderFor(m => m.GroupCountry).SetLabelPresentation(FormLabelPresentation.Group).SetGroupIcon("bi bi-globe2").SetQuickSelectVariant(VariantStyle.Success).Render()

Hidden label

C#
@model DMBFormBuilderLabs.Models.FormBuilderCountryExampleModel

@Html.CountryFieldBuilderFor(m => m.HiddenCountry).SetLabelPresentation(FormLabelPresentation.Hidden).Render()

Validation And State

Required country

Required field
C#
@model DMBFormBuilderLabs.Models.FormBuilderCountryExampleModel

@Html.CountryFieldBuilderFor(m => m.RequiredCountry).Render()

Locked country

C#
@model DMBFormBuilderLabs.Models.FormBuilderCountryExampleModel

@Html.CountryFieldBuilderFor(m => m.DisabledCountry).SetDisabled().Render()
Required field

Code Examples

CountryFields.cshtml
@Html.CountryFieldBuilderFor(m => m.Country).Render()
@Html.CountryFieldBuilderFor(m => m.FloatingCountry).SetLabelPresentation(FormLabelPresentation.Floating).Render()
@Html.CountryFieldBuilderFor(m => m.InlineCountry).SetLabelPresentation(FormLabelPresentation.Inline).Render()
@Html.CountryFieldBuilderFor(m => m.GroupCountry).SetLabelPresentation(FormLabelPresentation.Group).SetGroupIcon("bi bi-globe2").SetQuickSelectVariant(VariantStyle.Success).Render()
@Html.CountryFieldBuilderFor(m => m.HiddenCountry).SetLabelPresentation(FormLabelPresentation.Hidden).Render()
@Html.CountryFieldBuilderFor(m => m.RequiredCountry).Render()
@Html.CountryFieldBuilderFor(m => m.DisabledCountry).SetDisabled().Render()