<div class="row justify-content-center">
  <div class="col-8">
    <form name="editForm" role="form" novalidate (ngSubmit)="save()" [formGroup]="editForm">
      <h2
        id="jhi-e-pregunta-cerrada-heading"
        data-cy="EPreguntaCerradaCreateUpdateHeading"
        jhiTranslate="dataSurveyApp.ePreguntaCerrada.home.createOrEditLabel"
      >
        Create or edit a E Pregunta Cerrada
      </h2>

      <div>
        <jhi-alert-error></jhi-alert-error>

        <div class="form-group" [hidden]="editForm.get('id')!.value == null">
          <label class="form-control-label" jhiTranslate="global.field.id" for="field_id">ID</label>
          <input type="number" class="form-control" name="id" id="field_id" data-cy="id" formControlName="id" [readonly]="true" />
        </div>

        <div class="form-group">
          <label class="form-control-label" jhiTranslate="dataSurveyApp.ePreguntaCerrada.nombre" for="field_nombre">Nombre</label>
          <input type="text" class="form-control" name="nombre" id="field_nombre" data-cy="nombre" formControlName="nombre" />
          <div *ngIf="editForm.get('nombre')!.invalid && (editForm.get('nombre')!.dirty || editForm.get('nombre')!.touched)">
            <small class="form-text text-danger" *ngIf="editForm.get('nombre')?.errors?.required" jhiTranslate="entity.validation.required">
              This field is required.
            </small>
            <small
              class="form-text text-danger"
              *ngIf="editForm.get('nombre')?.errors?.minlength"
              jhiTranslate="entity.validation.minlength"
              [translateValues]="{ min: 1 }"
            >
              This field is required to be at least 1 characters.
            </small>
            <small
              class="form-text text-danger"
              *ngIf="editForm.get('nombre')?.errors?.maxlength"
              jhiTranslate="entity.validation.maxlength"
              [translateValues]="{ max: 500 }"
            >
              This field cannot be longer than 500 characters.
            </small>
          </div>
        </div>

        <div class="form-group">
          <label class="form-control-label" jhiTranslate="dataSurveyApp.ePreguntaCerrada.tipo" for="field_tipo">Tipo</label>
          <select class="form-control" name="tipo" formControlName="tipo" id="field_tipo" data-cy="tipo">
            <option [ngValue]="null">{{ 'dataSurveyApp.PreguntaCerradaTipo.null' | translate }}</option>
            <option value="SINGLE">{{ 'dataSurveyApp.PreguntaCerradaTipo.SINGLE' | translate }}</option>
            <option value="MULTIPLE">{{ 'dataSurveyApp.PreguntaCerradaTipo.MULTIPLE' | translate }}</option>
          </select>
          <div *ngIf="editForm.get('tipo')!.invalid && (editForm.get('tipo')!.dirty || editForm.get('tipo')!.touched)">
            <small class="form-text text-danger" *ngIf="editForm.get('tipo')?.errors?.required" jhiTranslate="entity.validation.required">
              This field is required.
            </small>
          </div>
        </div>

        <div class="form-group">
          <label class="form-control-label" jhiTranslate="dataSurveyApp.ePreguntaCerrada.opcional" for="field_opcional">Opcional</label>
          <input type="checkbox" class="form-check" name="opcional" id="field_opcional" data-cy="opcional" formControlName="opcional" />
          <div *ngIf="editForm.get('opcional')!.invalid && (editForm.get('opcional')!.dirty || editForm.get('opcional')!.touched)">
            <small
              class="form-text text-danger"
              *ngIf="editForm.get('opcional')?.errors?.required"
              jhiTranslate="entity.validation.required"
            >
              This field is required.
            </small>
          </div>
        </div>

        <div class="form-group">
          <label class="form-control-label" jhiTranslate="dataSurveyApp.ePreguntaCerrada.orden" for="field_orden">Orden</label>
          <input type="number" class="form-control" name="orden" id="field_orden" data-cy="orden" formControlName="orden" />
          <div *ngIf="editForm.get('orden')!.invalid && (editForm.get('orden')!.dirty || editForm.get('orden')!.touched)">
            <small class="form-text text-danger" *ngIf="editForm.get('orden')?.errors?.required" jhiTranslate="entity.validation.required">
              This field is required.
            </small>
            <small class="form-text text-danger" [hidden]="!editForm.get('orden')?.errors?.number" jhiTranslate="entity.validation.number">
              This field should be a number.
            </small>
          </div>
        </div>

        <div class="form-group">
          <label class="form-control-label" jhiTranslate="dataSurveyApp.ePreguntaCerrada.encuesta" for="field_encuesta">Encuesta</label>
          <select class="form-control" id="field_encuesta" data-cy="encuesta" name="encuesta" formControlName="encuesta">
            <option [ngValue]="null"></option>
            <option
              [ngValue]="encuestaOption.id === editForm.get('encuesta')!.value?.id ? editForm.get('encuesta')!.value : encuestaOption"
              *ngFor="let encuestaOption of encuestasSharedCollection; trackBy: trackEncuestaById"
            >
              {{ encuestaOption.id }}
            </option>
          </select>
        </div>
      </div>

      <div>
        <button type="button" id="cancel-save" data-cy="entityCreateCancelButton" class="btn btn-secondary" (click)="previousState()">
          <fa-icon icon="ban"></fa-icon>&nbsp;<span jhiTranslate="entity.action.cancel">Cancel</span>
        </button>

        <button
          type="submit"
          id="save-entity"
          data-cy="entityCreateSaveButton"
          [disabled]="editForm.invalid || isSaving"
          class="btn btn-primary"
        >
          <fa-icon icon="save"></fa-icon>&nbsp;<span jhiTranslate="entity.action.save">Save</span>
        </button>
      </div>
    </form>
  </div>
</div>
