How to access field in custom widget?
- Dominant language
- JavaScript
- Stars
- 634
- Forks
- 46
- PR merge metrics
- No merged PRs in 30d
Description
I'm building a custom widget that I want to render differently depending on if the field data is valid or not.
How do I check the valid state from a widget?
```
var React = require('react'),
Base = require('newforms').TextInput;
var UnderlineInput = Base.extend({
constructor: function UnderlineInput(kwargs) {
if(!(this instanceof UnderlineInput)) {
return new UnderlineInput(kwargs);
}
Base.call(this, kwargs);
}
});
UnderlineInput.prototype.render = function(name, value, kwargs) {
var finalAttrs = this.buildAttrs(kwargs.attrs, {
name: name
});
var valueAttr = kwargs.controlled ? 'value' : 'defaultValue';
finalAttrs[valueAttr] = value;
return (
$
);
};
module.exports = UnderlineInput;
```
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.