pInputText label not working on reactive form update

Post Reply
kztyler
Posts: 2
Joined: 04 Oct 2016, 13:40

07 Dec 2017, 17:40

I have a problem when using a simple text input with floating label, whenever i update the value of the fields in my form using patchValue, the UI keeps the label on top of the value of the field. I have tried focusing the element programatically and it doesnt fix it, but if you click on the actual element using the UI, then all the labels get fixed

this is the code of the view

Code: Select all

<div class="ui-g-12 ui-md-6">
      <span class="md-inputfield">
        <input #first type="text" pInputText formControlName="codigo">
        <label>Codigo</label>
      </span>
      <div class="input-error" *ngIf="determinacionForm.get('codigo').hasError('required') && determinacionForm.get('codigo').touched">
        Ingrese el Codigo
      </div>
    </div>
and this is the code of the component

Code: Select all

this.determinacionForm = this.fb.group({
      codigo: ['', Validators.required],
      abreviatura: ['', Validators.required],
      nombre: ['', Validators.required],
      habilitado: [],
      tipo: [],
      protocoloId: [],
      especialidadId: ['', Validators.required],
      peso: ['', Validators.required],
      unidadesBioquimicas: ['', Validators.required],
      valoresReferencia: [],
      obrasSociales: [],
      derivada: [false]
    }, {
        validator: this.hasProtocolo
      });

    this.determinacionForm.patchValue(this.determinacion);
Image

paulswan
Posts: 94
Joined: 27 Apr 2017, 08:19

10 Dec 2017, 23:53

I have seen this myself in the past. I haven't tried it but it might work if you call the updateFilledState() method of the InputText class.

Post Reply

Return to “Ultima - PrimeNG”

  • Information
  • Who is online

    Users browsing this forum: No registered users and 5 guests