ionic-framework icon indicating copy to clipboard operation
ionic-framework copied to clipboard

<ion-datetime displayFormat="MM"> does not bind to FormGroup

Open kazigais opened this issue 10 years ago • 5 comments

Ionic version: (check one with "x") [X ] 2.x

I'm submitting a ... (check one with "x") [ X] bug report

Current behavior: datetime does not bind to FormGroup if the format is "MM".

Expected behavior: Bind data to FormGroup.

Steps to reproduce: Create FormGroup and try to bind datetime with the format "MM".

Related code: this.cardForm = this.formBuilder.group({ 'name': ['', Validators.required], 'number': ['', Validators.required], 'exp_month': ['', Validators.required], 'exp_year': ['', Validators.required], 'cvc': ['', Validators.required] });

<form [formGroup]="cardForm" (ngSubmit)="requestToken($event)"> <ion-item> <ion-input formControlName="name" placeholder="Card Holder Name" type="text"></ion-input> </ion-item> <ion-item> <ion-input formControlName="number" placeholder="Card Number" size="16" maxlength="16" type="number"></ion-input> </ion-item> <ion-item> <ion-datetime formControlName="exp_month" displayFormat="MM" pickerFormat="MM"></ion-datetime> </ion-item> <ion-item> <ion-datetime formControlName="exp_year" displayFormat="YYYY" max="2050-10-31"></ion-datetime> </ion-item> <ion-item> <ion-input formControlName="cvc" placeholder="cvc" maxlength="3" size="3" type="number"></ion-input> </ion-item> <button block ion-button type="submit">Create</button> </form>

The output when I console.log(this.cardForm.value): screen shot 2016-12-01 at 12 43 47

The MM does not appear in exp_month whereas the YYYY appears in exp_year

Cordova CLI: 6.4.0 Ionic Framework Version: 2.0.0-rc.3 Ionic CLI Version: 2.1.12 Ionic App Lib Version: 2.1.7 Ionic App Scripts Version: 0.0.43 ios-deploy version: 1.9.0 ios-sim version: 5.0.6 OS: macOS Sierra Node Version: v4.0.0 Xcode version: Xcode 8.1 Build version 8B62




kazigais avatar Dec 01 '16 10:12 kazigais

The same with me! I updated Ionic to 2.0.1 and still with this problem.

<ion-datetime displayFormat="MM" formControlName="month"></ion-datetime>

M or MM don't works. If I change to any other displayFormat: YYYY, HH, h, hh.... works fine.

Some prevision when will fix it?

Cordova CLI: 6.4.0 Ionic Framework Version: 2.0.1 Ionic CLI Version: 2.1.18 Ionic App Lib Version: 2.1.9 Ionic App Scripts Version: 0.0.47 ios-deploy version: 1.9.0 ios-sim version: 5.0.13 OS: OS X El Capitan Node Version: v6.9.1 Xcode version: Xcode 7.3.1 Build version 7D1014

bbcbreno avatar Feb 13 '17 17:02 bbcbreno

Same here:

<ion-datetime cancelText="Cancelar" doneText="Listo" formControlName="desbaste" minuteValues="0,1,2,3,4,5,6,7,8,9,10" displayFormat="m%" pickerFormat="m" tappable></ion-datetime>

leandroz avatar Feb 20 '17 19:02 leandroz

A fix for now is to use ionChange grab the event and then: this.form.patchValue({ desbaste: event.minute.value });

leandroz avatar Feb 20 '17 19:02 leandroz

Another workaround is use a hour format: displayFormat="hh" (visually is the same than month). And after take a substring like this: month.substring(0,2)

bbcbreno avatar Feb 20 '17 20:02 bbcbreno

Thanks for the issue! This issue is being closed due to inactivity. If this is still an issue with the latest version of Ionic, please create a new issue and ensure the template is fully filled out.

Thank you for using Ionic!

ionitron-bot[bot] avatar Mar 26 '18 17:03 ionitron-bot[bot]