While an entity type's form controller class might be the primary form by which to edit an entity, it should be possible to create additional forms: for example, an in-place editing form, as in #1824500: In-place editing for Fields. Also, entities can be edited outside of forms entirely, via RESTful web services, as in #1826688: REST module: PATCH/update.

What is currently done by hook_node_prepare() and friends has nothing to do with forms: it's just about doing further manipulation of $node that wasn't done in node_load() for various reasons (performance, idempotence).

So, this patch moves it to the entity class itself.

Files: 
CommentFileSizeAuthor
#3 entity_prepare.patch6.65 KBeffulgentsia
FAILED: [[SimpleTest]]: [MySQL] Unable to apply patch entity_prepare_0.patch. Unable to apply patch. See the log in the details link for more information. View
entity_prepare.patch6.03 KBeffulgentsia
FAILED: [[SimpleTest]]: [MySQL] 48,741 pass(es), 453 fail(s), and 174 exception(s). View

Comments

effulgentsia’s picture

Note that the above patch doesn't move the implementation of ViewFormControllerBase::prepareEntity(), because there seems to be a little more coupling there to the form itself. For example, the "add" and "clone" forms skip that preparation.

Status: Needs review » Needs work

The last submitted patch, entity_prepare.patch, failed testing.

effulgentsia’s picture

Status: Needs work » Needs review
FileSize
6.65 KB
FAILED: [[SimpleTest]]: [MySQL] Unable to apply patch entity_prepare_0.patch. Unable to apply patch. See the log in the details link for more information. View

ViewUI is a strange class.

Wim Leers’s picture

#3: entity_prepare.patch queued for re-testing.

Status: Needs review » Needs work

The last submitted patch, entity_prepare.patch, failed testing.

Version: 8.0.x-dev » 8.1.x-dev

Drupal 8.0.6 was released on April 6 and is the final bugfix release for the Drupal 8.0.x series. Drupal 8.0.x will not receive any further development aside from security fixes. Drupal 8.1.0-rc1 is now available and sites should prepare to update to 8.1.0.

Bug reports should be targeted against the 8.1.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.2.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.1.x-dev » 8.2.x-dev

Drupal 8.1.9 was released on September 7 and is the final bugfix release for the Drupal 8.1.x series. Drupal 8.1.x will not receive any further development aside from security fixes. Drupal 8.2.0-rc1 is now available and sites should prepare to upgrade to 8.2.0.

Bug reports should be targeted against the 8.2.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.3.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.