Skip to content

Instantly share code, notes, and snippets.

@travist
Created June 5, 2018 14:47
Show Gist options
  • Save travist/a701ac5ebf3f6fe72f568e82db684493 to your computer and use it in GitHub Desktop.
Save travist/a701ac5ebf3f6fe72f568e82db684493 to your computer and use it in GitHub Desktop.
Override a Form.io component
// This shows how to override a Form.io component by extending it and creating your own methods.
import SelectComponent from 'formiojs/components/select/Select';
import Components from 'formiojs/components/Components';
export default class CustomSelect extends SelectComponent {
constructor(component, options, data) {
// Force all selects to use the html5 widget.
component.widget = 'html5';
super(component, options, data);
}
}
// Override the 'select' component to use our custom class instead.
Components.setComponent('select', CustomSelect);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment