Skip to content

Instantly share code, notes, and snippets.

@transcendr
Created September 22, 2023 14:44
Show Gist options
  • Save transcendr/714fb21e82bc2fe9d7e2c50676feefc5 to your computer and use it in GitHub Desktop.
Save transcendr/714fb21e82bc2fe9d7e2c50676feefc5 to your computer and use it in GitHub Desktop.
<div *ngFor="let group of objectKeys(formGroups)">
<form #formElement [formGroup]="formGroups[group]" [action]="formData?.action" [method]="formData?.method">
<ng-container *ngFor="let node of formData?.nodes">
<div *ngIf="node.group === group || node.group === 'default'">
<div *ngIf="node.messages.length > 0">
<mat-error>
{{ node.messages[0] }}
</mat-error>
</div>
<mat-form-field *ngIf="node.attributes.type !== 'hidden' && node.attributes.type !== 'submit'">
<input matInput [formControlName]="node.attributes.name" [name]="node.attributes.name" [type]="node.attributes.type" [placeholder]="node.meta.label?.text || ''">
</mat-form-field>
<input *ngIf="node.attributes.type === 'hidden'" type="hidden" [formControlName]="node.attributes.name">
<button mat-raised-button *ngIf="node.attributes.type === 'submit'" [type]="node.attributes.type">
{{ node.meta.label?.text }}
</button>
</div>
</ng-container>
</form>
</div>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment