Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug(calendar): yearpicker wont show value with reactive forms #11223

Closed
DwieDima opened this issue Feb 22, 2022 · 1 comment · Fixed by #11574
Closed

Bug(calendar): yearpicker wont show value with reactive forms #11223

DwieDima opened this issue Feb 22, 2022 · 1 comment · Fixed by #11574
Labels
Type: Bug Issue contains a bug related to a specific component. Something about the component is not working
Milestone

Comments

@DwieDima
Copy link

DwieDima commented Feb 22, 2022

Current behavior

Using reactive forms together with p-calendar and view="year" wont update the value inside input after using form.setValue('2022');
Currently you just see an empty string in input.
For view="month" this works as expected.

Expected behavior
Input field of calendar should show the initialized year using form.setValue().

Minimal reproduction of the problem with instructions

  public form!: FormGroup;
  constructor(private fb: FormBuilder) {}

  ngOnInit() {
     const exampleYear = '2022';

     this.form = this.fb.group({
        year: ['', [Validators.required]]
      });

     this.form.get('year').setValue(exampleYear);
  }
<div [formGroup]="form">
    <p-calendar
       view="year"
       dateFormat="yy"
       dataType="string"
       formControlName="year"
       ></p-calendar>
</div>

The same code, but for month is working properly.

edit

Also if you provide an initial value, it won't display.

     this.form = this.fb.group({
        year: ['2022', [Validators.required]]
      });
  • Angular version: 13.2.2
  • PrimeNG version: 13.2.0
  • Browser: [Chrome latest]
@MohammadRayanShah
Copy link

I would like to work on this issue

volvachev added a commit to volvachev/primeng that referenced this issue Jun 1, 2022
@cetincakiroglu cetincakiroglu added the Type: Bug Issue contains a bug related to a specific component. Something about the component is not working label Jun 7, 2022
@cetincakiroglu cetincakiroglu added this to the 13.4.2 milestone Jun 7, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: Bug Issue contains a bug related to a specific component. Something about the component is not working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants