Could this function be refactored and shared between widgets? Maybe we could put fields in their own object to make that easier, like `config.fields`.