Is there a working example of programmatically creating a webform?
I just need to see what works. The smallest excerpt will be helping out a lot. I can build on a foundation.
Drupal Answers is a question and answer site for Drupal developers and administrators. It only takes a minute to sign up.Sign up to join this community
When you look around how to programmatically create a node you will finde patterns like this:
$node = Node::create([ 'type' => 'article', 'title' => 'Druplicon test', 'field_image' => [ 'target_id' => $file->id(), 'alt' => 'Hello world', 'title' => 'Goodbye world' ], ]); $node->save();
Maybe that's similar for webforms or webform submissions? Okay, let's scan Webform's codebase for the following patterns:
WebformSubmission::create. Wow! Lots of samples just in the module's code! Let's take these two as a start:
Note that you also automatically can create webforms (not webform submissions, but webforms) by exporting config on one environment and importing it on different environments.