import { Component, OnInit } from '@angular/core';
import { FieldType } from '@ngx-formly/core';


@Component({
  selector: 'formly-multi-schema-type',
  template: `
        <label *ngIf="props.label" class="form-label">{{ props.label }}</label>
        <p *ngIf="props.description">{{ props.description }}</p>
        <div class="alert alert-danger" role="alert" *ngIf="showError && formControl.errors">
            <formly-validation-message [field]="field"></formly-validation-message>
        </div>
        <formly-field *ngFor="let f of field.fieldGroup" [field]="f"></formly-field>
  `,
})
export class MultiSchemaTypeComponent extends FieldType implements OnInit {
    ngOnInit() {
        let f = this.field
        f.fieldGroup![0].props!.options!.forEach(function (option) {
            option.label = f.fieldGroup![1].fieldGroup![option.value].props!.label;
            f.fieldGroup![1].fieldGroup![option.value].props!.label = "";
        });
    }
}


/**  Copyright 2021 Formly. All Rights Reserved.
    Use of this source code is governed by an MIT-style license that
    can be found in the LICENSE file at https://github.com/ngx-formly/ngx-formly/blob/main/LICENSE */
