Following the example here: https://www.drupal.org/docs/8/modules/webform/webform-cookbook/how-to-programmatically-add-a-handler-to-a-new-webform

I've created my handler manager sucessfully, however, when I go to create the handler, I get the error

Error: Unsupported operand types in Drupal\webform\Plugin\WebformHandlerBase->setConfiguration() (line 363 of /var/www/sitename/web/modules/contrib/webform/src/Plugin/WebformHandlerBase.php

Here's a sample of the code I'm using to get this error

$webform_machine_name = 'form_id';
$webform = \Drupal\webform\Entity\Webform::load($webform_machine_name);

$handler_manager = \Drupal::service('plugin.manager.webform.handler');

// Create webform handler.
$handler_configuration = [
  'id' => 'my_form_handler',
  'label' => 'My form handler',
  'handler_id' => 'my_form_handler',
  'status' => 1,
  'weight' => 0,
  'settings' => [],

$handler = $handler_manager->createInstance('my_form_handler', $handler_configuration );

1 Answer 1


When I look at line 263 in \Drupal\webform\Plugin\WebformHandlerBase there is the below code...

$this->configuration = $configuration['settings'] + $this->defaultConfiguration();

Your Unsupported operand types error message indicates that one of those variables/properties is not an array.

My best guess is that \Drupal\webform\Plugin\WebformHandlerBase::defaultConfiguration is not returning an array() because your $configuration['settings'] is set to an empty array.

  • Thanks for this. I discovered that I had commented out the contents of the defaultConfiguration method, so it was returning null. Oops. Apr 6, 2018 at 8:10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.