Skip to content

docs(dialog): add an option field to the form example #3513

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Apr 29, 2025
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 36 additions & 1 deletion src/components/dialog/examples/dialog-form.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ interface FormValue {
name: string;
age: number;
percentage: number;
color: string;
}

/**
Expand All @@ -39,6 +40,7 @@ export class DialogFormExample {
name: 'Harry Potter 🪄',
age: 44,
percentage: 40,
color: 'red',
};

@State()
Expand Down Expand Up @@ -81,6 +83,37 @@ export class DialogFormExample {
},
},
},
color: {
type: 'string',
title: 'Favorite color',
oneOf: [
{
type: 'string',
const: 'red',
title: 'Red',
},
{
type: 'string',
const: 'yellow',
title: 'Yellow',
},
{
type: 'string',
const: 'green',
title: 'Green',
},
{
type: 'string',
const: 'blue',
title: 'Blue',
},
{
type: 'string',
const: 'black',
title: 'Black',
},
],
},
},
};

Expand Down Expand Up @@ -149,7 +182,9 @@ export class DialogFormExample {

private submitForm = () => {
this.isSaving = true;
alert(`${this.formValue?.name} is ${this.formValue?.age} years old`);
alert(
`${this.formValue?.name} is ${this.formValue?.age} years old. Favorite color is ${this.formValue?.color}.`,
);
this.closeDialog();
};

Expand Down