Skip to content

Commit

Permalink
docs: describe each formly extension
Browse files Browse the repository at this point in the history
  • Loading branch information
MaxKless committed Mar 16, 2021
1 parent 38fcf7d commit ae88122
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
import { FormlyExtension } from '@ngx-formly/core';

/**
* Extension that ensures the validators property is always filled.
* This prevents some errors that come with undefined properties.
*/
export const criticalDefaultValuesExtension: FormlyExtension = {
prePopulate(field): void {
if (field.validators?.validation) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@ import { FormlyExtension } from '@ngx-formly/core';
import { isObservable, of } from 'rxjs';
import { map } from 'rxjs/operators';

/**
* Extension that automatically hides select fields when their options are empty.
*/
export const hideIfEmptyOptionsExtension: FormlyExtension = {
prePopulate(field): void {
if (field.type !== 'ish-select-field') {
Expand Down
4 changes: 4 additions & 0 deletions src/app/shared/formly/extensions/post-wrappers-extension.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
import { FormlyConfig, FormlyExtension, FormlyFieldConfig, FormlyTemplateOptions } from '@ngx-formly/core';

/**
* Extension that enables appending wrappers to the default configuration.
* It uses the templateOptions.postWrappers to modify a fields wrappers without overriding them.
*/
class PostWrappersExtension implements FormlyExtension {
constructor(private formlyConfig: FormlyConfig) {}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,12 @@ import { TranslateService } from '@ngx-translate/core';
import { isObservable, of } from 'rxjs';
import { map, startWith, tap } from 'rxjs/operators';

/**
* Extension to translate the templateOptions.options and add a placeholder element.
* It will use the TranslateService to translate option labels.
* Also, if templateOptions.placeholder is set, the extension will add a placeholder element.
* These modified options are written to templateOptions.processedOptions.
*/
class TranslateSelectOptionsExtension implements FormlyExtension {
constructor(private translate: TranslateService) {}

Expand Down

1 comment on commit ae88122

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Azure Demo Servers are available:

Please sign in to comment.