Problem/Motivation

The following error is thrown when a webform element is deleted:

	Error: Call to undefined method Drupal\webform_ui\Form\WebformUiElementDeleteForm::getEntity() in entity_mesh_form_alter() (line 116 of /var/www/html/docroot/modules/contrib/entity_mesh/entity_mesh.module).

Error on webform element delete

CommentFileSizeAuthor
webform-field-delete-error.png56.8 KBfrouco
Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

frouco created an issue. See original summary.

frouco’s picture

Issue summary: View changes
frouco’s picture

Title: PHP error on webform field delete » PHP error on webform element delete
frouco’s picture

Issue summary: View changes

lpeidro made their first commit to this issue’s fork.

lpeidro’s picture

Assigned: Unassigned » lpeidro
lpeidro’s picture

The issue is that the getEntity() method is not implemented in all form classes — only in those that extend from ContentEntityForm.
To avoid this error, we should first check whether the form object is an instance of ContentEntityDeleteForm, or a compatible class, before calling the method.

$form_object = $form_state->getFormObject();
  if (!$form_object instanceof ContentEntityDeleteForm) {
    return;
  }

It is ready for QA.

lpeidro’s picture

Status: Active » Needs review

frouco’s picture

Status: Needs review » Reviewed & tested by the community

After applying the patch, deleting a webform element works correctly.

lpeidro changed the visibility of the branch 3526552-php-error-on to hidden.

  • lpeidro committed d570f6fb on 1.x authored by frouco
    Issue #3526552: PHP error on webform element delete
    
lpeidro’s picture

Status: Reviewed & tested by the community » Fixed

Status: Fixed » Closed (fixed)

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