How to validate input fields in a Modal Page


#1

Hi there,

Is it possible to validate the input fields from a modal page with reactive forms?

I’ve been doing it with regular ionic pages but for some reason it is not working when I try the same in a modal page.

I noticed that the form values were updated but not my object. I checked many times my code and it seems ok. So I am asking myself if there’s maybe a structure thing that doesn’t allow us to use reactive forms with modals? Is that a thing?

If it’s possible, has anyone done it, and have a simple example?

If not, I suppose I should use template forms, ngModel and validate each field manually when data is submitted, right?

Any suggestions? What did I miss?

Thanks!


#2

I’m so sorry everyone, I wish I could delete this post :sweat_smile:

I just missed the most important step and for some reason I thought the trouble was caused by the modal page!

So, answering myself my stupid question I forgot to set the form values to my object on a submit method.

this.myObject = this.myReactiveForm.value;

Sorry again, and thanks again!
:v: