Skip to content

Commit

Permalink
add error messages to ComboBox examples
Browse files Browse the repository at this point in the history
  • Loading branch information
vursen committed Sep 25, 2024
1 parent 0fd0f41 commit fd00c6e
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 0 deletions.
1 change: 1 addition & 0 deletions frontend/demo/component/combobox/combo-box-validation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ export class Example extends LitElement {
allowed-char-pattern="[A-Z]"
label="Country code"
helper-text="2-letter uppercase ISO country code"
error-message="Field is required"
allow-custom-value
.items="${['DE', 'FI', 'US']}"
></vaadin-combo-box>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ function Example() {
allowedCharPattern="[A-Z]"
label="Country code"
helperText="2-letter uppercase ISO country code"
errorMessage="Field is required"
allowCustomValue
items={['DE', 'FI', 'US']}
/>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.vaadin.demo.component.combobox;

import com.vaadin.flow.component.combobox.ComboBox;
import com.vaadin.flow.component.combobox.ComboBox.ComboBoxI18n;
import com.vaadin.flow.component.orderedlayout.HorizontalLayout;
import com.vaadin.flow.router.Route;
import com.vaadin.demo.DemoExporter; // hidden-source-line
Expand All @@ -15,6 +16,8 @@ public ComboBoxValidation() {
ComboBox<String> field = new ComboBox<>();
field.setRequiredIndicatorVisible(true);
field.setAllowedCharPattern("[A-Z]");
field.setI18n(new ComboBoxI18n()
.setRequiredErrorMessage("Field is required"));
// end::snippet[]
field.setLabel("Country code");
field.setHelperText("2-letter uppercase ISO country code");
Expand Down

0 comments on commit fd00c6e

Please sign in to comment.