nebular icon indicating copy to clipboard operation
nebular copied to clipboard

datepicker submit my form

Open zerr0s opened this issue 2 years ago • 1 comments

Hello,

I'm new in using nebular. I have a reactive form and the datepicker is in a formgroup:

<form [formGroup]="subscriptionForm" (ngSubmit)="onSubmit(subscriptionForm)">
<p>
<input nbInput fullWidth formControlName="birthday" placeholder="Date de naissance" [nbDatepicker]="dateTimePicker" />
</p>
<nb-datepicker #dateTimePicker format="DD-MM-yyyy"></nb-datepicker>

When I use the buttons on top of the datepicker component (month/year selection), the component is submiting my form. How shoud I disable this behaviour ?

Thanks

zerr0s avatar Sep 14 '23 14:09 zerr0s

Hello, would you like to try by adding $event.preventDefault() to the ngSubmit?

<form [formGroup]="subscriptionForm" (ngSubmit)="$event.preventDefault(); onSubmit(subscriptionForm)">
<p>
<input nbInput fullWidth formControlName="birthday" placeholder="Date de naissance" [nbDatepicker]="dateTimePicker" />
</p>
<nb-datepicker #dateTimePicker format="DD-MM-yyyy"></nb-datepicker>

EmreAka avatar Jan 16 '24 06:01 EmreAka