-
Notifications
You must be signed in to change notification settings - Fork 3.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(module:form): support form label wrap (#7892)
- Loading branch information
1 parent
71c2138
commit 37391de
Showing
7 changed files
with
101 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
--- | ||
order: 14 | ||
title: | ||
zh-CN: 表单标签可换行 | ||
en-US: Label can wrap | ||
--- | ||
|
||
## zh-CN | ||
|
||
使用 `nzLabelWrap` 可以开启 `label` 换行。 | ||
|
||
## en-US | ||
|
||
Turn on `nzLabelWrap` to wrap label if text is long. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
import { Component, OnInit } from '@angular/core'; | ||
import { UntypedFormBuilder, UntypedFormGroup, Validators } from '@angular/forms'; | ||
|
||
@Component({ | ||
selector: 'nz-demo-form-label-wrap', | ||
template: ` | ||
<form nz-form [formGroup]="validateForm" (ngSubmit)="submitForm()"> | ||
<nz-form-item> | ||
<nz-form-label nzRequired nzFor="user" nzSpan="3"> Normal text label </nz-form-label> | ||
<nz-form-control nzErrorTip="Please input your username!" nzSpan="8"> | ||
<input formControlName="userName" nz-input id="user" /> | ||
</nz-form-control> | ||
</nz-form-item> | ||
<nz-form-item> | ||
<nz-form-label nzRequired nzFor="password" nzSpan="3" nzLabelWrap> | ||
Long text label Long text label | ||
</nz-form-label> | ||
<nz-form-control nzErrorTip="Please input your Password!" nzSpan="8"> | ||
<input formControlName="password" nz-input type="password" id="password" /> | ||
</nz-form-control> | ||
</nz-form-item> | ||
<nz-form-item> | ||
<nz-form-control nzSpan="12" style="text-align: center"> | ||
<button nz-button nzType="primary">Log in</button> | ||
</nz-form-control> | ||
</nz-form-item> | ||
</form> | ||
` | ||
}) | ||
export class NzDemoFormLabelWrapComponent implements OnInit { | ||
validateForm!: UntypedFormGroup; | ||
|
||
submitForm(): void { | ||
console.log('submit', this.validateForm.value); | ||
} | ||
|
||
constructor(private fb: UntypedFormBuilder) {} | ||
|
||
ngOnInit(): void { | ||
this.validateForm = this.fb.group({ | ||
userName: [null, [Validators.required]], | ||
password: [null, [Validators.required]], | ||
remember: [true] | ||
}); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters