<form appFormSubmit (ngSubmit)="objectController.actionCallback(primaryAction)" [formGroup]="poolForm">
  <!--suppress JSUnusedGlobalSymbols -->
  <app-form-errors #formErrors [formGroup]="poolForm"></app-form-errors>
  <app-fl-backdrop *ngIf="loading"></app-fl-backdrop>
  <div layoutDirection="column">
    <mat-form-field>
      <mat-label i18n>Name</mat-label>
      <input matInput placeholder="Name" i18n-placeholder type="text" formControlName="name" required>
      <mat-error>{{fieldErrors['name']}}</mat-error>
    </mat-form-field>
    <mat-form-field>
      <mat-label i18n>Description</mat-label>
      <input matInput placeholder="Description" i18n-placeholder type="text" formControlName="description">
      <mat-error>{{fieldErrors['description']}}</mat-error>
    </mat-form-field>
    <mat-form-field *ngIf="createOptions">
      <mat-label i18n>Algorithm</mat-label>
      <mat-select placeholder="Algorithm" i18n-placeholder formControlName="lb_algorithm" required>
        <mat-option *ngFor="let poolAlgorithm of createOptions.pool_supported_algorithms"
                    [value]="poolAlgorithm">
          {{createOptions.pool_algorithms[poolAlgorithm]}}
        </mat-option>
      </mat-select>
    </mat-form-field>
    <div *ngIf="createOptions" formGroupName="session_persistence"
         layoutDirection="row" layoutDirection-xs="column" appLayoutGap="10px">
      <mat-form-field appFlex="50%" xsFlex="100">
        <mat-label i18n>Session persistence</mat-label>
        <mat-select placeholder="Session persistence" i18n-placeholder
                    formControlName="type">
          <mat-option [value]="''" i18n>(none)</mat-option>
          <mat-option *ngFor="let s of createOptions.session_persistence_types | keyvalue"
                      [value]="s.key">
            {{s.value}}
          </mat-option>
        </mat-select>
      </mat-form-field>
      <mat-form-field *ngIf="poolForm.getRawValue()['session_persistence']['type'] === 'APP_COOKIE'"
                      appFlex="50%" xsFlex="100">
        <mat-label i18n>Cookie name</mat-label>
        <input matInput placeholder="Cookie name" i18n-placeholder type="text" formControlName="cookie_name" required>
        <mat-error>{{fieldErrors['cookie_name']}}</mat-error>
      </mat-form-field>
    </div>
    <mat-checkbox formControlName="admin_state_up" color="primary" i18n>Admin state up</mat-checkbox>
  </div>
</form>
