# LDC DYNAMIC FORM

## Usage

```html

<lib-ldc-dynamic-form
        [fields]="fields"
        [buttons]="buttons"
        [alignButtons]="alignButtons"
        (onSubmit)="onSubmit($event)"
        (onClose)="onClose($event)"
>
</lib-ldc-dynamic-form>
```

```typescript
import {Component} from '@angular/core';

@Component({
    selector: 'app-root',
    templateUrl: './app.component.html'
})
export class AppComponent {
    alignButtons = "end";
    fields = [
        <IFormControl<ITextInput>>{
            controller: {
                name: "title",
                controller: this._fb.control(payload?.title ?? null, [
                    Validators.required,
                ]),
            },
            containerStyle: "mb-3",
            placeholder: "enterTitle",
            type: formControlType.input,
            controllerSpecification: <ITextInput>{
                inputType: inputType.text,
            },
            isAutofocus: false,
            isAutocomplete: true,
            columnSize: 6,
            translateLangType: null,
            controllerStyle: null,
        },
    ];
    buttons = [
        {
            matType: ButtonTypes.flat,
            color: ButtonColors.primary,
            text: "submit",
            buttonType: "submit",
        },
        {
            matType: ButtonTypes.flat,
            color: ButtonColors.warn,
            text: "cancel",
            buttonType: "button",
            clicked: async () => {
                this._snackBar.dismiss();
                await this._router.navigate(["/dashboard/virtual-expo"]);
            },
        },
    ];

    onSubmit(e:any) {
        console.log("submit",e);
    }

    onClose(e:any) {
        console.log("close",e);
    }
}
```

### Properties

| Name           | Type                    | Description           |
|----------------|-------------------------|-----------------------|
| `fields`       | `IFormControl<Filed>[]` | Inputs specification  |
| `buttons`      | `IButton[]`             | Buttons specification |
| `alignButtons` | `AlignButtons`          | Buttons alignment     |

### Events

| Name       | Type                | Description  |
|------------|---------------------|--------------|
| `onSubmit` | `EventEmitter<any>` | Submit event |
| `onClose`  | `EventEmitter<any>` | Close event  |
