Luis Alberto Santana
Luis Alberto Santana

Reputation: 337

Angular Formly: Adding more information to a model

I've been using Angular Formly to render some forms from the JSON response I get from services, however I have a couple of questions.

  1. It is possible to obtain data in a field (templateOptions.label for example) to add to the model? Or it is necessary to overwrite FormlyFormController from formly-form.js and add a function as the existing "attachKey"?

  2. You can add a field, say groupLabel to a fieldGroup, so as to render a title for the group?

Upvotes: 0

Views: 1637

Answers (1)

kentcdodds
kentcdodds

Reputation: 29021

(moved from comment)

You can definitely add a new type for the groupLabel and use that, or you could simply use the template property.

For the obtaining field data question... it kind of depends on what you're trying to do. You definitely have access to that property, and you can even make a custom controller. I would recommend looking at the Creating Custom Templates lesson in the angular-formly docs and use the options property to get access to the field configuration and the model property to get access to the model.

Upvotes: 1

Related Questions