# Form inside modal returning undefined

**URL:** <https://forum.ionicframework.com/t/form-inside-modal-returning-undefined/96662>\
**Category:** ionic-v3\
**Created:** [July 3, 2017, 1:47am UTC](https://forum.ionicframework.com/t/form-inside-modal-returning-undefined/96662 "2017-07-03T01:47:25Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![mpreyes](https://avatars.discourse-cdn.com/v4/letter/m/c37758/32.png) [@mpreyes](https://forum.ionicframework.com/u/mpreyes)\
**Post date:** [July 3, 2017, 1:47am UTC](https://forum.ionicframework.com/t/form-inside-modal-returning-undefined/96662/1 "2017-07-03T01:47:25Z")

</div>

Hello!  
–v2  
I am trying to create a simple form inside a modal that takes the information the user entered and displays it in the previous page. I have called the form: addform and the home page: mhome.

My form calls the closeModal() function:

```auto
export class Addform {
  private addform : FormGroup;

  constructor(private formBuilder: FormBuilder, public storage: Storage,public navCtrl: NavController, public viewCtrl: ViewController) {
    this.addform = this.formBuilder.group({
      name: ['', Validators.required],
      occupation: [''],
      dob: [''],
      relationship: [''],
        color: [''],
      adjectives: [''],

    });

  }
  closeModal(){
  // this.navCtrl.push(MhomePage,this.addform);
  // console.log();
  // let data = this.addform;
 **let data = this.addform;** //This is the part I'm confused on. How do I set the formbuilder group variables to the data variable?
  this.viewCtrl.dismiss();

  }

```

The openModal() function

```auto
  openModal() {

     let modal = this.modalCtrl.create(Addform);
     modal.onDidDismiss((data) => {
        console.log("Data =>", data);
     });
     modal.present();

  }

```

Hitting the + button pops open the form page. The console shows that the data is undefined.

 ![image](https://global.discourse-cdn.com/ionicframework/original/3X/a/1/a17f020977edde06a1b35637d582b6833799b6ad.png)

Any help would be appreciated!

---

<div class="post-metadata">

**Author:** ![AaronSterling](https://avatars.discourse-cdn.com/v4/letter/a/51bf81/32.png) [@AaronSterling](https://forum.ionicframework.com/u/AaronSterling)\
**Post date:** [July 3, 2017, 1:53am UTC](https://forum.ionicframework.com/t/form-inside-modal-returning-undefined/96662/2 "2017-07-03T01:53:11Z")

</div>

Demonstrated here.

> **[Ionic Framework](https://ionicframework.com/docs/api/components/modal/ModalController/)**
>
> Ionic is the app platform for web developers. Build amazing mobile, web, and desktop apps all with one shared code base and open web standards

---

<div class="post-metadata">

**Author:** ![mpreyes](https://avatars.discourse-cdn.com/v4/letter/m/c37758/32.png) [@mpreyes](https://forum.ionicframework.com/u/mpreyes)\
**Post date:** [July 3, 2017, 2:18am UTC](https://forum.ionicframework.com/t/form-inside-modal-returning-undefined/96662/3 "2017-07-03T02:18:42Z")

</div>

Thanks for that. How would I access each individual component in the form builder group though?  
In the example that they show, they have the user id already set.

```auto
let profileModal = this.modalCtrl.create(Profile, { userId: 8675309 });

```

//So they can then pass it along and do things with the user id

```auto
 let modal = this.modalCtrl.create(Addform, addform.name( I know this part is wrong) );

```

how would I access the value the user entered in the formbuilder group to pass it to the modal?

Sorry if this seems obvious!
