Skip to content

Commit 6b380c6

Browse files
Display required hint according to settings
1 parent 242ff7d commit 6b380c6

File tree

2 files changed

+11
-9
lines changed

2 files changed

+11
-9
lines changed

src/Presentation/SmartStore.Web/Models/Common/AddressModel.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,10 +60,12 @@ public AddressModel()
6060
[AllowHtml]
6161
public string CountryName { get; set; }
6262
public bool CountryEnabled { get; set; }
63+
public bool CountryRequired { get; set; }
6364

6465
[SmartResourceDisplayName("Address.Fields.StateProvince")]
6566
public int? StateProvinceId { get; set; }
6667
public bool StateProvinceEnabled { get; set; }
68+
public bool StateProvinceRequired { get; set; }
6769

6870
[SmartResourceDisplayName("Address.Fields.StateProvince")]
6971
[AllowHtml]

src/Presentation/SmartStore.Web/Views/Shared/Partials/_CreateOrUpdateAddress.cshtml

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -82,16 +82,16 @@
8282
@if (Model.CountryEnabled)
8383
{
8484
<div class="form-group row">
85-
@Html.LabelFor(model => model.CountryId, new { @class = "col-{0}-3 col-form-label required".FormatInvariant(breakpoint) })
85+
@Html.LabelFor(model => model.CountryId, new { @class = "col-{0}-3 col-form-label{1}".FormatInvariant(breakpoint, Model.CountryRequired ? " required" : "") })
8686
<div class="col-@breakpoint-9">
8787
@Html.DropDownList("CountryId", Model.AvailableCountries,
88-
new
89-
{
90-
@class = "form-control country-input country-selector",
91-
data_region_control_selector = "#Address_StateProvinceId",
92-
data_states_ajax_url = Url.Action("GetStatesByCountryId", "Country"),
93-
data_addEmptyStateIfRequired = "true"
94-
})
88+
new
89+
{
90+
@class = "form-control country-input country-selector",
91+
data_region_control_selector = "#Address_StateProvinceId",
92+
data_states_ajax_url = Url.Action("GetStatesByCountryId", "Country"),
93+
data_addEmptyStateIfRequired = "true"
94+
})
9595
@Html.ValidationMessageFor(model => model.CountryId)
9696
</div>
9797
</div>
@@ -100,7 +100,7 @@
100100
@if (Model.CountryEnabled && Model.StateProvinceEnabled)
101101
{
102102
<div class="form-group row">
103-
@Html.LabelFor(model => model.StateProvinceId, new { @class = "col-{0}-3 col-form-label".FormatInvariant(breakpoint) })
103+
@Html.LabelFor(model => model.StateProvinceId, new { @class = "col-{0}-3 col-form-label{1}".FormatInvariant(breakpoint, Model.StateProvinceRequired ? " required" : "") })
104104
<div class="col-@breakpoint-9">
105105
@Html.DropDownListFor(model => model.StateProvinceId, Model.AvailableStates, new { @class = "form-control" })
106106
@Html.ValidationMessageFor(model => model.StateProvinceId)

0 commit comments

Comments
 (0)