Radio inputs in a model driven form: access its values


#1

Hi!

Can anyone help me with radio inputs in a model driven form ? Thanks!

The error:
Error in ./SettingsPage class SettingsPage - inline template:60:19 caused by: No value accessor for form control with name: 'lang'

For my app settings I am reusing the settings code from the Ionic Super starter template.

This is my view:
<form [formGroup]=“form”>

    <ion-list *ngIf="page == 'language'" radio-group>
      <ion-list-header>
        language
      </ion-list-header>

      <ion-item>
        <ion-label>English</ion-label>
        <ion-radio formControlName="lang" value="en" [checked]="(lang=='en')"></ion-radio>
      </ion-item>

      <ion-item>
        <ion-label>Nederlands</ion-label>
        <ion-radio formControlName="lang" value="nl" [checked]="(lang=='nl')"></ion-radio>
      </ion-item>

    </ion-list>

  </form>

My SettingsPage class:

_buildForm(){
  let group: any = {
    remindTime:   [this.options.remindTime],
    remindAgenda: [this.options.remindAgenda],
    remindNotify: [this.options.remindNotify]
  }

  switch(this.page) {
    case 'reminders':
      break;
    case 'language': 
    group =  {
      lang: [this.options.lang]
    };
    break;
  }

  this.form = this.formBuilder.group(group);
}