0

I'm at a loss.

I'm using WebForm 8.x-5.2 on Drupal 8.7.3. I have a custom webform handler that takes the submission and creates an unpublished node for review. The webform includes an image field that saves one or more images submitted through the form in the Private Files area as suggested.

Everything in my submission handler works as expected except for the images. Upon viewing the page created by the handler, the images are not displayed. The images are there. If you simply edit the node in the UI and save it, the images show up. I've tried a bunch of things, without success...

  • Saving files to the public files directory
  • Adding code to the handler to save the node a second time
  • Adding code to the handler to make a change to the Title field after saving and then saving again.

Inspecting the node with Devel before and after the manual edit/save shows no difference that I can see. Here's the relevant code snippets...

$values = $webform_submission->getData();
if (!$webform_submission->isDraft()) {
  $node = Node::create([
  ...
  'field_image' => $values['image'],
  ...
 ]);
 ...
$node->save();

My submission handler is setting taxonomy terms, multiple fields, URLs, and everything is working except for the images. What am I missing?

0

I would agree with cchen - you need to use the URI of the image to print it - and I'm not sure 'field_image' => $values['image'] would work in this case.

|improve this answer|||||

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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