-
Notifications
You must be signed in to change notification settings - Fork 403
How to use fieldTransform with promises? #748
Comments
I think this would be better suited for your controller than inside formly conifg. Before setting .fields in your scope, make your ajax call and apply the mutation there. I think this makes more sense to do in the controller than within formly transform, |
@egucciar I'd agree with that if we had one form, but we have multiple formly-forms in multiple applications, where they all need to have this intercepted functionality. |
I still wouldn't think it's appropriate for fieldTransforms but that's just me. How about an injectable service that can do the mutation and wrap your calls? That way if in any case you do not not require the mutation it is trivial not to have it. |
Another issue is the nesting of fields/fieldgroups. If I am using a service to do the manipulation myself, I'll have to do a recursive check on all sub-fields and -groups. |
That doesn't sound like an issue. I also created a form mutator for my project and believe it's a superior approach from an architecture perspective as this can scale to scenarios where a global configuration object would make it more difficult to use straight formly forms with no mutation applied. |
Hi,
In our application we have a requirement for theme-specific fields. In the documentation I found the 'fieldTransform', where you can manipulate the fields before formly compiles them, which seemed like the ideal place for the theme manipulation.
Our theme is loaded by doing a call to obtain a json config file, where the manipulition is defined. The fieldTransform however cannot handle promises, so I have to block the http call before the returning of the fields.
Simple example:
Controller:
And the
run
block:How can I make this asynchronous?
The text was updated successfully, but these errors were encountered: