Example of how to use hook to alter value

Created on 12 February 2012, over 13 years ago
Updated 6 February 2023, over 2 years ago

I have a token from webform [webform:webform-val-number_of_guests] that I want to multiple by ticket price to insert that into a field in the PDF.

Can you provide any help on this?

Thanks.

📌 Task
Status

Active

Version

4.0

Component

Documentation

Created by

🇬🇧United Kingdom bjalford

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • 🇵🇰Pakistan Allahnoor Turab

    For me it is not working with drupal version 9.5.2 and fillpdf version 5.0
    I not see any output.
    I want this hook to remove prefix and change date format for some fields
    /**
    * Implements hook_fillpdf_merge_fields_alter().
    */
    function miscellaneous_fillpdf_merge_fields_alter(&$fields, $context) {
    dump($fields);
    // $submission = end($webforms); // Gets the last sid passed.
    // $ticket_price = 5.00; // @todo: Replace with code to get this from the webform object.
    // $fields['The rent is'] *= $ticket_price; // Multiply number of guests by ticket price.
    }

  • 🇨🇦Canada Liam Morland Ontario, CA 🇨🇦

    I thought dump() was a Twig function. It won't work in a hook implementation. If devel module is enabled, you should be able to use dpm().

  • 🇵🇰Pakistan Allahnoor Turab

    No success, actually the hook is not triggering.

  • 🇨🇦Canada Liam Morland Ontario, CA 🇨🇦

    hook_fillpdf_merge_fields_alter() only exists in Drupal 7.

  • Status changed to Closed: outdated 3 days ago
  • 🇨🇦Canada Liam Morland Ontario, CA 🇨🇦

    Drupal 7 is no longer supported. If this applies to a supported version, please re-open.

Production build 0.71.5 2024