DEV Community

Discussion on: Building scalable robusts and type safe forms with Angular

Collapse
 
andrewtraub profile image
AndrewTraub

So do you have sample code that works with 2.7.1 or do I need to upgrade to angular 8 in order to get my code working?

Thanks,

Andrew

Thread Thread
 
maxime1992 profile image
Maxime

You can clone the project:

git clone git@github.com:cloudnc/ngx-sub-form.git

and checkout the latest version working with angular 7

git checkout v2.7.1

From there you'll have the README and the whole demo project working with Angular 7.

If you want to use new features that appeared after 2.7.1 or take advantage of the latest bug fixes you'll have to upgrade to Angular 8 and then use the latest of ngx-sub-form.

Hope it makes sense.
If you can and there's no particular blocker, I'd recommend upgrading to Angular 8 anyway :)

Thread Thread
 
andrewtraub profile image
AndrewTraub

Thanks. Is there any way to add a custom validation for the entire group? Normally, I'd do so like this:

createFormGroup() {
this.myForm = this.fb.group({
mobile : new FormControl(''),
homePhone : new FormControl('')
// our custom validator
}, { validator: this.atLeastOnePhoneRequired});
}

but in the form using ngx-sub-form I'm using code like this:
protected getFormControls(): Controls {
return {
mobile : new FormControl(null),
homePhone : new FormControl(null)
};
}

Thread Thread
 
maxime1992 profile image
Maxime

Yes, there's definitely a way to do that.

Search getFormGroupControlOptions on the README :)