Skip to content

Commit

Permalink
fix: show correct error message if description is too long
Browse files Browse the repository at this point in the history
  • Loading branch information
gion-andri committed Nov 7, 2023
1 parent 2e8ce1a commit 1ecb7cd
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/app/user-area/pages/new-event/new-event.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,12 @@ <h1>Registrar in’occurrenza</h1>
<textarea formControlName="description" class="form-control" id="description" style="height: 150px"
[class.is-invalid]="isFieldInvalid('description')"></textarea>
<div class="invalid-feedback" *ngIf="isFieldInvalid('description')">
Endatescha p.pl. ina descripziun.
<ng-container *ngIf="isFieldError('description', 'required')">
Endatescha p.pl. ina descripziun.
</ng-container>
<ng-container *ngIf="isFieldError('description', 'maxlength')">
La descripziun na dastga betg esser pli lunga che 750 caracters.
</ng-container>
</div>
<div id="descriptionHelp" class="form-text">Hilfe bei der Übersetzung auf Rumantsch / Aiuto con la
traduzione in
Expand Down
5 changes: 5 additions & 0 deletions src/app/user-area/pages/new-event/new-event.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,11 @@ export class NewEventComponent implements OnInit {
return occurrence.get(fieldName)!.invalid && (occurrence.get(fieldName)!.dirty || occurrence.get(fieldName)!.touched);
}

isFieldError(fieldName: string, errorName: string) {
const field = this.f.get(fieldName)!;
return field.hasError(errorName);
}

get genresFormArray(): FormArray {
return this.f.get('genres') as FormArray;
}
Expand Down

0 comments on commit 1ecb7cd

Please sign in to comment.