primeng icon indicating copy to clipboard operation
primeng copied to clipboard

Calendar should allow valid blank/null value

Open loftyduck opened this issue 9 years ago • 7 comments

I'm submitting a ... (check one with "x")

[x] bug report => Search github for a similar issue or PR before submitting

Plunkr Case (Bug Reports) http://plnkr.co/edit/sDos4A?p=preview

Current behavior A date control will remain invalid with errors: {invalidDate: true} when the input value is changed from a value to null.

This may have been introduced with the fix for issue #1676

Expected behavior By default, a date control should have no validation errors when its value is null.

Minimal reproduction of the problem with instructions See plunkr above. Steps:

  1. Enter a value into the Date/Time (calendar) field
  2. Delete the value from the field
  3. The formControl still has errors: invalidDate: true

What is the motivation / use case for changing the behavior? If a null value is always invalid then it seems to be impossible to have a calendar control that is optional on a given FormGroup.

Please tell us about your environment: MacOS Sierra 10.12.3

  • Angular version: 2.2.1

  • PrimeNG version: 2.0.0 to 2.0.5

  • Browser: Chrome Version 57.0.2987.133 (64-bit)

  • Language: TypeScript 2.0.6

  • Node (for AoT issues): n/a

loftyduck avatar Apr 07 '17 21:04 loftyduck

Bug still exists in version >4.

vorenus181 avatar Jun 07 '17 17:06 vorenus181

Is there any solutions?

morganRotaStabelli avatar Jun 12 '17 15:06 morganRotaStabelli

Any solution? I have one case for a non required date field which after writing and deleting the value, the entire form becomes invalid exposing this error object

{ "invalidDate": true }

diego-toro avatar Jun 12 '17 20:06 diego-toro

Will review for 4.1.0 final.

cagataycivici avatar Jun 22 '17 13:06 cagataycivici

How to allow p-calendar to display only years. I didn't found any property for this. could you please help me in this.

nagpvn2 avatar Aug 10 '17 05:08 nagpvn2

@nagpvn2 p-calendar doesn't have functionality to show only years.

I'd recommend using a dropdown or slider or autocomplete with options defined corresponding to your expected year range.

loftyduck avatar Aug 10 '17 14:08 loftyduck

v7.1.0 p-calendar does not emit change even when using formControlName and leave null value. It does appear to be blank on the input, but never trigger valueChanges in the formControl. Any idea? image It does trigger on valid value though...

namdien177 avatar Jul 23 '19 04:07 namdien177