Views API custom table not showing fields I'm creating a custom view that corresponds to my module's table.

I already called the hook_views_api() hook.

function sample_views_api() {
    return [
        'api' =&gt; 3,
        'path' =&gt; drupal_get_path('module', 'sample')
    ];
}


To generate the view I called the hook_views_default_views() hook.

function sample_views_default_views() {
    $view = new view;
    $view-&gt;name = 'sample';
    $view-&gt;description = '';
    $view-&gt;tag = 'default';
    $view-&gt;base_table = 'sample_table';
    $view-&gt;human_name = 'Sample';
    $view-&gt;core = 7;
    $view-&gt;api_version = '3.0';
    $view-&gt;disabled = false;

    $handler = $view-&gt;new_display('page', 'Page', 'page');
    $handler-&gt;display-&gt;display_options['path'] = 'sample';
    $handler-&gt;display-&gt;display_options['menu']['type'] = 'normal';
    $handler-&gt;display-&gt;display_options['menu']['title'] = 'Sample';
    $handler-&gt;display-&gt;display_options['menu']['weight'] = '0';

    $views['sample'] = $view;

    return $views;
}


But when I opened my generated views. The fields of the corresponding table does not show.



Any way to show the fields? Am I missing something to register the fields?
In order for Views to work with custom tables, you need to tell Views about your data structure with hook_views_data. The writeup and comments on that page will help you define the guts of the implementation. You basically have to tell views about the table, any relationships (and how), and describe each field in your table and what handler/filter etc it can have.

Aside from that, Data can help wire this automatically, but note that this will require re-defining your table/schema using the Data API.