What about a CRUD Support for entities? Like node/add/%type, node/%node/add, node/%node/edit, node/%node/delete? Any plans? Does that make sense?
Maybe in an extended UI controller and with views support like "Content Overview" and Edit/Delete links.

There various implementations (e.g. micro, profile2) but not a simple one. I think this would be a good example for other developers. I would like to contribute ...

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

scroogie’s picture

The profile2_page module which is a submodule of profile2 is an example of how to create the UI for creation, editing, etc.

Damien Tournoud’s picture

EntityDefaultUIController provides some of that, but could definitely use some love.

scroogie’s picture

I thought EntityDefaultUIController is more for custom admin forms, like the profile types in profile2. IMHO, the OP means content forms that appear in the "Add content" pane.

scroogie’s picture

I tried to use it to provide node-like add/edit forms, but I'll need an example. Can't figure it out myself.

fago’s picture

Title: CRUD for Entities? » UI controller for content-entities

EntityDefaultUIController was written with admin UI for configuration-entities in mind. We might want to improve it to properly work for content-entities too or add an alternate UI controller dedicated for that case.

fmizzell’s picture

sub

fago’s picture

Category: feature » task

Coming from #1619628: Entity UI '/add' page doesn't provide for an entity with bundles - we should do this first.

-> Let's add "EntityContentUIController" - A UI controller for content entities outputting usual local tasks.

We need to add an entity page view callback, what shouldn't be hard and can follow the profile2_pages + node examples.

joachim’s picture

Because I was working on a project that had a LOT of custom content entity types, I wrote this to quickly build reusable UIs for them: https://drupal.org/project/entity_operations

fago’s picture

entity_operations looks indeed interesting. I think we should provide basic operations here out of the box (as we partly already have) and make sure we play nice with entity-operations for extending it with further ones? Do you see any problems with such an approach?

dasjo’s picture

Status: Active » Needs review
FileSize
3.72 KB

here's a first patch that adds a EntityContentUIController.
the controller unsets the entities base menu item and adds 'view', 'edit' and 'delete' menu items.

joachim’s picture

Status: Needs review » Needs work
+++ b/includes/entity.ui.inc
@@ -492,6 +492,76 @@ class EntityDefaultUIController {
+    $wildcard = '%entity_object';

In the parent class at least, this is only the default. You need to look at $this->entityInfo['admin ui']['menu wildcard'].

(It would be a big help if the base class set the wildcard as an object property, to save repeating this. But that's another issue.)

+++ b/includes/entity.ui.inc
@@ -492,6 +492,76 @@ class EntityDefaultUIController {
+    unset($items[$this->path]);

This needs a comment to explain what's being removed.

> I think we should provide basic operations here out of the box (as we partly already have) and make sure we play nice with entity-operations for extending it with further ones? Do you see any problems with such an approach?

That should be fine.

Entity Operations provides a UI controller class which currently extends EntityDefaultUIController. It checks for entity operations for 'view', 'add', and 'edit', and if they're present, replaces the paths from Entity API's UI controller. So that would still be fine.

Furthermore, while it wasn't a design goal, it's actually perfectly possible to add entity operation tabs to entities that already have other output. For example, you can add an entity operation tab to the user entity.

dasjo’s picture

thank you for your feedback joachim!

i have adapted the wildcard logic + documented unset.

the attached patch also contains some further fixes + cleanup.

dasjo’s picture

Fixed the non-existing redirect, caused by unsetting the manage type menu item.

dasjo’s picture

sorry the last patch was broken. the interdiff is still valid

dasjo’s picture

Fixed the redirect for the operation form (delete).

dasjo’s picture

sorry #15 is redundant & wrongly named. just forget this one, it was caused by some local dev confusion of mine :)

fago’s picture

Status: Needs review » Needs work
+++ b/includes/entity.ui.inc
@@ -492,6 +492,79 @@ class EntityDefaultUIController {
+      'access callback' => 'entity_access',
+      'access arguments' => array('edit', $this->entityType),

This misses $entity as argument.

dasjo’s picture

addresses #17

fago’s picture

Status: Needs review » Fixed

Thanks. I improved the docs a bit + made $page == TRUE for the page callback and committed it.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.