Skip to content

Commit

Permalink
feat: introduce template option 'inputClass' to set css classes at in…
Browse files Browse the repository at this point in the history
…put/select/textarea tags in formly components
  • Loading branch information
SGrueber committed Dec 7, 2021
1 parent bb1a47c commit 0a7ccaa
Show file tree
Hide file tree
Showing 8 changed files with 14 additions and 7 deletions.
2 changes: 2 additions & 0 deletions docs/guides/formly.md
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,8 @@ Refer to the tables below for an overview of these parts.

### Field Types

Template option `inputClass`: These css class(es) will be added to all input/select/textarea tags.

| Name | Description | Relevant templateOptions |
| -------------------- | -------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------- |
| ish-text-input-field | Basic input field, supports all text types | type: 'text' (default),'email','tel','password' |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ export class SelectOrderTemplateFormComponent implements OnInit {
type: 'ish-radio-field',
key: 'orderTemplate',
templateOptions: {
inputClass: 'position-static',
fieldClass: ' ',
value: 'new',
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ export class SelectWishlistFormComponent implements OnInit {
type: 'ish-radio-field',
key: 'wishlist',
templateOptions: {
inputClass: 'position-static',
fieldClass: ' ',
value: 'new',
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
type="checkbox"
[formControl]="formControl"
[formlyAttributes]="field"
[attr.data-testing-id]="field.key"
class="form-check-input"
[ngClass]="to.inputClass"
[attr.data-testing-id]="field.key"
/>
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<input
class="form-check-input"
[ngClass]="{ 'position-static': !to.label }"
type="radio"
[formControl]="formControl"
[value]="to.value"
[id]="id"
class="form-check-input"
[ngClass]="to.inputClass"
[attr.data-testing-id]="'radio-' + to.label"
/>
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<select
class="form-control"
[formControl]="formControl"
[compareWith]="to.compareWith ? to.compareWith : defaultOptions.templateOptions.compareWith"
[class.custom-select]="to.customSelect"
[formlyAttributes]="field"
class="form-control"
[ngClass]="to.inputClass"
[attr.data-testing-id]="field.key"
>
<ng-container *ngIf="selectOptions && selectOptions | formlySelectOptions: field | async as opts">
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
<input
[type]="to.type"
[formControl]="formControl"
class="form-control"
[formlyAttributes]="field"
class="form-control"
[ngClass]="to.inputClass"
[attr.data-testing-id]="field.key"
/>
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
[formControl]="formControl"
[cols]="to.cols"
[rows]="to.rows"
class="form-control"
[formlyAttributes]="field"
class="form-control"
[ngClass]="to.inputClass"
[attr.data-testing-id]="field.key"
></textarea>

0 comments on commit 0a7ccaa

Please sign in to comment.