Page 1 of 1

pInputText label not working on reactive form update

Posted: 07 Dec 2017, 17:40
by kztyler
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

Re: pInputText label not working on reactive form update

Posted: 10 Dec 2017, 23:53
by paulswan
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.