- Issue created by @srees
- Status changed to Needs review
over 1 year ago 8:08pm 15 March 2023 - πΊπΈUnited States srees
I'm not sure this is the best way to solve it, but I've written a patch that is working for me.
- Status changed to Closed: works as designed
over 1 year ago 11:44pm 26 May 2023 - πΊπΈUnited States jrockowitz Brooklyn, NY
It seems like you are doing some custom theming. You should use webform elements to sort the fields in the Twig template or create a custom preprocessor that sorts the submission data.
/** * Implements hook_preprocess_entity_print(). */ function THEME_preprocess_entity_print(array &$variables) { $webform_submission = _webform_entity_print_preprocess_entity_print_get_webform_submission($variables['content']); if (!$webform_submission) { return; } // Order the submission data to match the Webform fields $get_data = $webform_submission->getData(); $set_data = array(); foreach (array_keys($webform_submission->getWebform()->getElementsDecodedAndFlattened()) as $key){ if(isset($get_data[$key])){ $set_data[$key] = $get_data[$key]; } } $webform_submission->setData($set_data); $variables['webform_submission'] = $webform_submission; }
- πΊπΈUnited States srees
I do not understand how this cannot be a bug. Did you try my steps to reproduce? The only "custom" thing I'm doing is taking advantage of the option within the attached PDF field to generate output from embedded TWIG.
The twig template is receiving the data in the order it is set in the webform. This is expected. However viewing a link to the PDF is in order of key, which is not expected. These should be uniform without me having to customize through a hook.
I'm not even asking that the TWIG template be honored in the online version of the PDF (though that would be logical). Just that data be provided in a consistent format.