Change record status: 
Project: 
Introduced in branch: 
8.x-5.x
Introduced in version: 
8.x-5.0-rc8
Description: 

Webform submission form id no longer includes the source entity type and id was reverted.

The webform submission form id now includes the source entity.

Here is the full pattern for a webform submission form id.

{WEBFORM_ID}_{SOURCE_ENTITY_TYPE}_{SOURCE_ENTITY_ID}_{OPERATION}

For example, when the Contact webform is attached to a Webform Node the hook_form_FORM_ID_alter() is ...

/**
  * Implements hook_form_FORM_ID_alter().
  */
function CUSTOM_MODULE_form_webform_submission_contact_node_12345_add_form_alter(&$form, \Drupal\Core\Form\FormStateInterface $form_state){
...
}

Also, The webform submission base form id now includes the webform id.

Instead of...

/**
  * Implements hook_form_BASE_FORM_ID_alter().
  */
function CUSTOM_MODULE_form_webform_submission_add_form_alter(&$form, \Drupal\Core\Form\FormStateInterface $form_state){
...
}

...the required hook is now...

/**
  * Implements hook_form_BASE_FORM_ID_alter().
  */
function CUSTOM_MODULE_form_webform_submission_contact_add_form_alter(&$form, \Drupal\Core\Form\FormStateInterface $form_state){
...
}

Below are the different hook, form id, and implementations available for the default Contact form (/form/contact).

  • hook_form_BASE_FORM_ID_alter() => {WEBFORM_ID} => hook_form_webform_submission_contact()
  • hook_form_FORM_ID_alter() => {WEBFORM_ID}_{OPERATION} => hook_form_webform_submission_contact_add()
  • hook_form_FORM_ID_alter() => {WEBFORM_ID}_{SOURCE_ENTITY_TYPE}_{SOURCE_ENTITY_ID}_{OPERATION} => hook_form_webform_submission_contact_node_1_add()

The below notification is displayed to webform administrator when the webform module is being updated.

AttachmentSize
Webforms Webform Demo Site.png103.01 KB
Impacts: 
Site builders, administrators, editors
Module developers
Themers

Comments

Dani Smith’s picture

Can anyone offer insight into WHERE/WHICH file needs this update? I am not a web developer but am stuck developing for my company and have NO idea what I am doing. We need this stupid update because our forms stopped being editable.
PLEASE HELP!

I am looking in the server for this file to update but I can't find where it is.

Any insight is helpful!

ashrafabed’s picture

Replying too late to be helpful to you, but in case anyone finds this question on Google (as I did).

A "hook" is a PHP function which follows a specific naming convention.

An example of a hook which can be utilized by developers is hook_form_FORM_ID_alter()

A developer would create a PHP function whose name matches that of the hook, except they would:
- Replace the word "hook" with the name of their custom module (or custom theme)
- Replace any words which are in all-caps (in this instance, FORM_ID) with an appropriate value (in this instance, the form's ID)

The developer would place the PHP function they created inside of their custom module's MODULENAME.module file (or their theme's THEMENAME.theme file). For example, if their module was named debugacademy, they would place the hook in a file named debugacademy.module, located within the debugacademy/ module folder (typically modules/custom/debugacademy/debugacademy.module)

So if you were looking for a hook to update it, you would look in:
- Your custom modules' MODULENAME.module file
- Your custom theme's THEMENAME.theme file

Hopefully this is helpful to someone.

I teach live project-based Drupal Training courses at Debug Academy.

I provide performant affordable Drupal hosting for smaller sites with automatic upgrades at Drupito.