Reputation: 452
I have several field types that I have created. They are similar to each other except their wrappers are different. One type may need wrapped in something that the other does not need (thus the multiple types were created).
Is it possible to pass wrappers to field types? Maybe something like this:
vm.fields=[
{
key: 'name',
type: 'fieldType1'
wrappers: ['wrapper1', 'wrapper2']
}
]
I am trying to use the least amount of field types for the sake of supporting this in the future. If the only difference between these types are the wrapper...I am hoping that I can inject the wrappers that I want into the type when I add the field to my field array.
Upvotes: 0
Views: 793
Reputation: 29021
You can actually define wrapper
as a field property (docs), like so:
vm.fields=[
{
key: 'name',
type: 'fieldType1'
wrapper: ['wrapper1', 'wrapper2']
}
]
(Notice, the only difference between this example and your code is it's wrapper
not wrappers
).
I realize (and apologize) that the name is confusing, but for what it's worth, you can specify a string or array of strings, so it would make sense in this case:
vm.fields=[
{
key: 'name',
type: 'fieldType1'
wrapper: 'wrapper1'
}
]
Upvotes: 2