I have created component with certain traits. I am not able to assign default value to traits by passing values. It is coming as undefined for color type, blank for text field.
traits: [ {
type: 'text',
label: 'Placeholder',
changeProp: 1,
name: 'placeholder',
value: 'Type your text here'
},
{
type: 'color',
label: 'Icon Color',
changeProp: 1,
name: 'iconColor',
value: '#000000'
}]

Any changes in field is getting reflected in component
Traits should read the default directly from their props/attributes, so in your case, it should be something like this:
iconColor: '#000000',
placeholder: 'Type your text here',
traits: [ {
type: 'text',
label: 'Placeholder',
changeProp: 1,
name: 'placeholder'
},
{
type: 'color',
label: 'Icon Color',
changeProp: 1,
name: 'iconColor'
}]
Thanks!
Hello @artf what about the select type ? It seems like we are not able to use a default value for select.. Keep in mind that options are dynamic ( I'm getting the options from a json that is being generate from back-end )so I'm not able to use something like that:
options: [
{value: 0, name: '1st option' },
{value: 1, name: '2nd option' }
]
code::
in your case, defaults should be like
typeid: 0 pointing to the first element as default
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.
Most helpful comment
Traits should read the default directly from their props/attributes, so in your case, it should be something like this: