Skip to content

Thanks and suggestion #1

Description

@AlexHoebart-ICPDR

Thank you very much @argiepiano for this very good and clear tutorial and that you introduced it at Backdrop LIVE!

I previously failed to create custom entities following some other docs. I don't remember how, but it was much more complicated and did not work well, so I gave up.
But with this tutorial it was really easy for me to follow and use it for my own application. Thanks!!

I have one suggestion, which could be useful to add to the ed4.module as it is also not so obvious:
Like it is now, the "created" field is just displayed as a number in a View, because it is an integer field in the table.
To make it a readable date field in a View, the Views handlers need to be adapted.

/**
 * Implements hook_views_data_alter(&$data)
 */
function ed4_views_data_alter(&$data) {
  // Set field handler for date fields
  $data['student']['created']['field']['handler'] = 'views_handler_field_date';

  // Set sort handler for date fields
  $data['student']['created']['sort']['handler'] = 'views_handler_sort_date';

  // Set filter handler for date fields
  $data['student']['created']['sort']['handler'] = 'views_handler_filter_date';
}

This works when placed in the ed4.module. According to docs, it should be in ed4.views.inc but then it needs a hook_views_api in ed4.module. I don't know why this would be needed like this, I guess just for clear separation.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions