I'm adding new fields to views through a custom module.
When I open the view page UI, the field is not shown. However, If I edit the view from the user interface, and click on Add field, the custom field is available.
How can I automatically add those fields to the list of fields to display on a view?
function mymodule_views_default_views() {
// …
$handler->display->display_options['fields']['myfield']['id'] = 'fieldname';
$handler->display->display_options['fields']['myfield']['table'] = 'databaseTableName';
$handler->display->display_options['fields']['myfield']['field'] = 'fieldname';
// …
}