1

I'm very new to angular - please be patient :) I would like to have a nested form - something like:

name:{
 firstname:"",
 lastname:"",
}

This is my "formly" function:

this.getFormFields = function (categories) {
     var meta={
        metadata:{
          title:"hello",
          description:"test123",
        }
     }
     return [{
        key: 'name',
        type: 'input',
        templateOptions: {
          label: gettextCatalog.getString('Name'),
          required: true
        }
      }, 
      {
          key: 'metadata',
          type: 'input',
          model:meta.metadata,
          templateOptions: {
            label: "metadata title",
           }
       },
      {
        key: 'clientId',
        type: 'input',
        templateOptions: {
        required:true,
        label: "clientId"
         }
       },
      }];
    };

So how to add nested fields?

0

1 Answer 1

2

You're in luck! This was just made insanely easy in angular-formly's 7.0.0 release (which was pushed out yesterday). Here's an example.

For your specific case, you'd probably do something like:

{
  key: 'name.firstname',
  type: 'input',
  templateOptions:  {
    label: 'First Name'
  }
}
Sign up to request clarification or add additional context in comments.

2 Comments

ahhh - awesome thats great. Problem is i'm using loopback angular-admin. But this is my problem then :) so i need to update it. Great thank you!
is it possible to make key name something like this key: name[0].firstname ?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.