Drupal 8 config webform review page

I actually managed to get there in the end by re-tracing how it is written in the first place looking through the Drupal Contrib API documentation

I thought I would answer this question as a decent guide for anyone wanting to do the same again, even if I can only give them answer in my specific example

My code is as follows

/**
  • Implements hook_node_insert(). / function mymodule_node_insert($node) { // Examines the node type of that being created if ($node->type == 'event') { // The declaration for how setting up the webform defaults // is done at this stage rather than after invoking the // function below $node->webform = abstract_webform_node_defaults(); // Adds the default settings for the abstract submission _abstract_webform_components($node); } } // Custom function to overwrite the normal defaults for webform // This notation was taken from link 1 - provided under answer function abstract_webform_node_defaults() { $defaults = array( 'confirmation' => '', 'confirmation_format' => NULL, 'redirect_url' => '<none>', 'teaser' => '0', 'block' => '0', 'allow_draft' => '1', 'auto_save' => '0', 'submit_notice' => '1', 'submit_text' => '', 'submit_limit' => '1', 'submit_interval' => '-1', 'total_submit_limit' => '-1', 'total_submit_interval' => '-1', 'status' => '1', 'record_exists' => FALSE, 'roles' => array_keys(user_roles(TRUE)), // Roles are normally written as array keys for users, I wanted everyone except anonymous users to be able to enter mine 'emails' => array(), 'components' => array(), 'conditionals' => array(), ); return $defaults; } / Custom function to setup webform as specific default */ function _abstract_webform_components($node) { $components = array( 0 => array( 'name' => 'First name', 'form_key' => 'first_name', 'type' => 'textfield', 'mandatory' => 1, 'weight' => 1, 'pid' => 0, 'extra' => array( 'private' => 0, ), ), 1 => array( 'name' => 'Body', 'form_key' => 'name', 'type' => 'textfield', 'mandatory' => 1, 'weight' => 2, 'pid' => 0, 'extra' => array( 'private' => 0, ), ), 2 => array( 'name' => 'Email address', 'form_key' => 'email_address', 'type' => 'email', 'mandatory' => 1, 'weight' => 3, 'pid' => 0, 'extra' => array( 'private' => 0, ), ), 3 => array( 'name' => 'Message', 'form_key' => 'message', 'type' => 'textarea', 'mandatory' => 1, 'weight' => 4, 'pid' => 0, 'extra' => array( 'private' => 0, ), ), ); // Iterate through each $component record and pass into node // Information on how to do this taken from link 2 webform_ensure_record($node); foreach($components as $component) { $component['nid'] = $node->nid; $component['extra']['title_display'] = 'inline'; $component['extra']['locked'] = 1; $node->webform['components'][] = $component; webform_component_insert($component); } // Retrieves information about the author $author = user_load($node->uid); // Adds the author of the node as a 'reviewer' $email = array( 'nid' => $node->nid, 'email' => $author->mail, 'subject' => 'default', 'from_name' => 'default', 'from_address' => 'default', 'template' => 'default', 'excluded_components' => array(), ); webform_email_insert($email); // This function returns the value of which component is called 'Body' so // that I can use its key for my validation rule, just so that if I re-arranged // my order at a later date, it would still keep the right key value for ($i = 0; $i < count($components); $i++) { if ($components[$i]['name'] == 'Body') { $body_component = $i+1; break; } } // If there is a 'Body' component if ($body_component) { // Validation formatting was taken from link 3 $validation = array( 'validator' => 'max_words', 'action' => 'add', 'nid' => $node->nid, 'rulename' => 'Maximum Abstract Length', 'rule_components' => array( $body_component => 'Body', ), 'data' => 300, ); webform_validation_rule_save($validation); } drupal_set_message(t('Abstract Submission created, Author set to reviewer by default.')); }

Credit goes to all the authors of commenters from the original questions and links provided

Link 1

Link 3

Also I would like to credit @Nebel54, for the suggestion about using the Webform Share to get a print out of exactly how your webform is written.

How do I add a handler to a webform in Drupal 8?

Add a remote submission handler to your webformGo to your forms Settings tab, then click on Emails/Handlers. Click on Add Handler. Select Remote post handler from the modal and fill in the Completed URL as the base URL that we will be submitting to. Remember to Save your handler.

How do I sanitize a Drupal webform?

Once inside the administration form, you can see all of your webforms. For each form that you want to sanitize, set the options. If you want to sanitize just one webform, click the 'Save all and sanitize [webform_id]' button. If you want to sanitize all webforms, click the 'Save and sanitize submissions' button.

How to place webform in block Drupal 8?

Create your webform..

Structure => Block Layout => click "Place Block" under your preferred region..

Find Webform then => Place Block => under Webform type your webform title and it will find it..

Save Block..

How to export data from webform in Drupal?

If you are using the webform module you can download submission's results in csv/xls files. if you want to do that go to: content => select the webform you need to export => click on the result tab => finaly click on the download button.