Search code examples
angularjsangular-formly

How to get data from an inner formlyform directive


I have a directive placed within my fields array. The directive has another formlyform within it which displays several fields. Whatever validations that these inner fields have (required/min/max/etc) are correctly displaying the validation message when failing. However, I am having troubles with getting the value of the fields to bubble up to the main form’s model.

Please take a look at this jsbin

Notice that the InnerFieldTest fields are being pulled from the formlyform placed within the exampleDirective. There is also one outerfieldtest field placed on the main formlyform. If you enter data into the three fields, the model only displays the data for the Outer field. I believe that I have a basic understanding why this is occurring (the model of the inner form is not represented within the model of the outerform). However, I am unsure in how to fix this issue.

Anyone have any suggestions?

PS…anyone also have ideas on how to get the inner formly to see the Submit btn call from the outer form? When I press the Submit btn on the main form...I want the inner form to be validated just like the main form (meaning anything missing that is required will turn red).


Solution

  • I have found a good way of accomplishing this. Take a look at this github sourcecode

    MacKentoch gave me a few tips on how to get the Model of an inner formly form that is within a directive. Thanks man!