From e65cec17d41f5563f2c5dde35422741f11e3fabb Mon Sep 17 00:00:00 2001
From: Mackinnon Buck
Date: Tue, 6 Jul 2021 09:19:20 -0700
Subject: [PATCH] Support for 'multiple' attribute in '
Ticket class:
-
+ @*We specify 'multiple' here, but it has no effect since we are not binding to an array type.*@
+
(select)
Economy class
Premium class
@@ -43,6 +44,23 @@
@person.TicketClass
+
+ @*Here, the 'multiple' attribute is inferred because we are binding to an array type.*@
+
+ San Francisco
+ Tokyo
+ London
+ Madrid
+
+
+
+
+ @("\"")
+ {
+ Empty string
+
+ @string.Join(", ", person.HostileStrings)
+
Airline:
@@ -158,6 +176,12 @@
[Required, StringLength(10), CustomValidationClassName(Valid = "valid-socks", Invalid = "invalid-socks")]
public string SocksColor { get; set; }
+ [Required, MinLength(2), MaxLength(3)]
+ public City[] SelectedCities { get; set; } = new[] { City.SanFrancisco };
+
+ [Required]
+ public string[] HostileStrings { get; set; } = new string[] { "\"", "{" };
+
public string Username { get; set; }
}
@@ -169,6 +193,8 @@
enum Country { Japan, Yemen, Latvia }
+ enum City { SanFrancisco, Tokyo, London, Madrid }
+
List submissionLog = new List(); // So we can assert about the callbacks
void HandleValidSubmit()
diff --git a/src/Components/test/testassets/BasicTestApp/SelectVariantsComponent.razor b/src/Components/test/testassets/BasicTestApp/SelectVariantsComponent.razor
index 7573b62fb305..1b79557168b5 100644
--- a/src/Components/test/testassets/BasicTestApp/SelectVariantsComponent.razor
+++ b/src/Components/test/testassets/BasicTestApp/SelectVariantsComponent.razor
@@ -20,14 +20,39 @@
}
+
+ Volvo
+ Saab
+ Opel
+ Audi
+
+
+@string.Join(", ", SelectedCars)
+
+
+ San Francisco
+ Los Angeles
+ Portland
+ Seattle
+
+
+@string.Join(", ", SelectedCities)
+
@code
{
public string SelectValue { get; set; } = "B";
+ public string[] SelectedCities { get; set; } = new[] { "\"sf\"", "\"sea\"" };
+ public string[] SelectedCars { get; set; } = new string[] { };
public bool ShowAdditionalOption = false;
void ToggleShowAdditionalOption() {
ShowAdditionalOption = true;
}
+
+ void SelectedCarsChanged(ChangeEventArgs e)
+ {
+ SelectedCars = (string[])e.Value;
+ }
}