Closed jimmed closed 9 years ago
Hi, I think you are referring to v0.4 docs.
Here the v0.5 docs: https://github.com/gcanti/tcomb-form/blob/master/GUIDE.md#templates.
Try with:
const formOptions = {
fields: {
// ...
bio: {
attrs: { // <-- this is the new v0.5 API to handle attributes and events
placeholder: 'A short description of yourself'
}
},
// ...
}
};
attrs
are provided to input components by a decorator.
Since you are tracing the source code, if it can be helpful:
Decorator definition:
https://github.com/gcanti/tcomb-form/blob/master/src/components.js#L80
Decorator usage:
https://github.com/gcanti/tcomb-form/blob/master/src/components.js#L249
Retrieving the attrs
:
https://github.com/gcanti/tcomb-form/blob/master/src/components.js#L273
Thanks for your quick response! I must admit I didn't check the version of the guide with respect to my local version of tcomb.
Not using attrs
was indeed my mistake! Consider this issue closed :+1:
I'm still fairly new to the ins and outs of tcomb-form, so please bear with me if I'm being silly.
I am using custom templates to generate a form, which has manually set placeholders on some fields.
In my custom form templates, I am logging the
locals
passed to the template, and it does not contain aplaceholder
property.I manually traced through the tcomb-form code, and it seems that the placeholder is never passed down to the template, despite examples to the contrary on the documentation. Looking at
Component.prototype.getLocals
, it seems that the placeholder never gets passed! By altering the given lines to the following, placeholders begin to appear in my form:Have I misunderstood tcomb-form, or is this a genuine bug?