Widget instantiation overrides

Some examples where you might override instantiation of widgets by customizing the widget factory.

In the configuration file for a theme,theme.config.json, you can use the "widgetFactory" to customize how widgets are instantiated by overriding entries that define the widget:

{
"widgetFactory": {
    "DateEdit": "cls.MyDateEditWidget",
    "SpinEdit": "cls.MyCustomSpinerWidget"
  }
}

This allows you to change all new instances of the given widgets to the ones defined in the theme.

For more information on widgetFactory and its use in theme configuration, go to theme.config.json file.

Example customizing the date picker widget

This customization involves making a change in the default theme for mobile devices, where instead of the standard mobile widget for DateTimeEdit, you force a fall back to using the default GBC DateTimeEdit widget.

For example, the GBC DateTimeEdit widget may be preferred as more ergonomic and easier to use, especially when users are entering a historical date such as a date of birth.

In the gbc-project-dir/theme/platform/mobile/theme.config.json, remove the theme setting for cls.DateEditMobileWidget :
{
  "conditions": ["isMobile"],
  "widgetFactory": {
    "DateEdit": "cls.DateEditMobileWidget",
    "DateTimeEdit": "cls.DateTimeEditMobileWidget",
    "TimeEdit": "cls.TimeEditMobileWidget",
    "SpinEdit": "cls.SpinEditMobileWidget"
  }
}

All new instances of the DateTimeEdit widget for mobile will use the default GBC DateTimeEdit widget.