Webform 4.x is out, and it has Token-driven token support. It uses the submission machine-readable name for its tokens, so I should figure out how to support this. I should probably replace both submission and webform tokens when in Webform-filling mode, and I can't really see any issue with this...yet. Alternatively, I could detect the major version of Webform and act accordingly, but that rarely ends well. So better probably to detect the submission token type.

Webform Tokens will still work with Webform 4.x tokens at the moment, but API-breaking changes are likely on the way, and as such, best to log this now and look into it soon.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

garidan’s picture

A have just installed webforms 4.x alpha 4 because I need webform rules, and it's its requirement.
In fillpdf I see no more webforms for token replacement.
Did anyone see that too ?
It could be a problem on my side, but probably it's not.

Thanks

poeticninja’s picture

The webform tokens do not show up unless you start looking for them. I have a blank token drop down arrow and when I click it the webform tokens shows up. So it gets renames from webform to blank. I just thought I would share what I found incase anyone else has this problem.

Denfish’s picture

Webform 7.x-4.0-alpha6
Webform Rules 7.x-1.4
Webform Tokens 7.x-1.1+3-dev

This can be reproduced. If Webform Rules is deactivated the problem goes away.

Screen shot for greater clarity:

ekidman’s picture

Not sure if this is the best thread to post this, but here it is:

I'm having issues with FillPDF since upgrading to webform 4 last week. I saw there are several posts about this, but I can't seem to find a solution. Is there any working combination of webform 7.x-4.0-alpha6 and FillPDF? None of the tokens seem to work, as they all come out blank in the final PDF. I read that there was an API change in webform that may have caused this.

I tried the 7.x-2.x-dev version of FillPDF, along with the PDF Forms API, but get the same results.

From what I've read, it appears the webform_tokens module may not be needed with the new versions of webform, as webform now includes tokens. However, turning off the webform_tokens module takes away all the "webform" tokens in the FillPDF settings. Upgrading to the dev version of webform tokens gives me an error when I try to open the PDF's.

Just can't seem to find any working combination of webform 7.x-4.0-alpha6 and FillPDF/webform_tokens - is anyone successfully using both?

My setup:
Drupal 7.18
FillPDF 7.x-1.9 (also tried 2.x-dev and 1.x-dev)
Webform Tokens 7.x-1.1
Webform 7.x-4.0-alpha6

wizonesolutions’s picture

Version: 7.x-1.x-dev » 7.x-2.x-dev
Priority: Normal » Critical

Sorry for the trouble you're having.

No, Webform Tokens and Fill PDF don't support Webform 4.x yet. It's Fill PDF that will need to (Webform Tokens is only about providing Token tokens because Webform 3 didn't have them).

Patches/sponsorship welcome if possible. In any case, upgrading this task to critical...although it'll still be a bit before I get to it.

If a 7.x-1.x patch is provided, I'm willing to commit it if it works. It shouldn't be too difficult to swap in Webform 4-compatible code. I just don't want to remove support for Webform 3 + Webform Tokens until 7.x-2.x.

enbl’s picture

Version: 7.x-2.x-dev » 7.x-1.x-dev
Priority: Critical » Normal

Edit: sorry, cross-post with answer above. To add as an FYI to others with this same problem: downgrading from Webform 4.x to 3.x is not currently possible unless you have a database backup from before running update.php. I started with Webform 4.x as one of the first modules I added, so I don't have any meaningful backups prior to adding it ): Time to start an entirely new site, I guess.
---
I'm having a similar problem. I can't get webform *data* to populate a form using the Webform Tokens module. If I disable Webform Rules, I can get webform tokens that *aren't* data to populate the form - e.g., webform:meta-sid and webform:meta-label-(component) work. But I cannot come up with any way to get any user-submitted values to populate.

I am using:
Drupal 7.15
Fill PDF 7.x-1.9 (also tried 2.x dev, does not produce a pdf at all under these circumstances)
Webform Tokens 7.x-1.1+3-dev
Webform 7.x-4.0-alpha6

See also this as-yet-unanswered stackexchange post.

ekidman’s picture

Priority: Normal » Critical
enbl’s picture

ekidman: A co-worker helped me develop code that can be added to fillpdf.module to make it work with Webform 4.x, which I believe will also cause it to stop working with Webform 3.x. It reformats webform 4.x input retrieved using webform_get_submission() to act like 3.x input; see here for a description of the relevant change between 3.x and 4.x.

wizonesolutions: please forgive my newbieness and not knowing how to make a patch (on major rush to complete project before tomorrow). I wanted to post this so ekidman could use it as a temporary solution if necessary.

In tokens.module, find the line

$token_objects['webform'] = $webform['submission'];

And place the following directly after it and before the line that begins with "$token":

foreach($webform['submission']->data as $index=>$value) {
       if($index or $index===0) {
               $webform['submission']->data[$index]['value'] = array(0=>$value[0]);
       }
}

Edit: make sure you have Webform Tokens enabled, have Webform Rules disabled, and are using the tokens Webform Tokens supplies (e.g., [webform:val-textmetest] for the value of element textmetest).

ekidman’s picture

enbl,

Great, I'll test it out at some point tomorrow. Thanks! If everything works as expected maybe we can make it into a patch.

c_archer’s picture

Status: Active » Needs review
FileSize
738 bytes

Hi,

I have tested the code and it worked for me. I have created a patch for this.

Cheers

ekidman’s picture

Just applied the patch, and it seems to fix the tokens issue. Thanks to both of you for your work on this!

wizonesolutions’s picture

Version: 7.x-1.x-dev » 7.x-2.x-dev
Status: Needs review » Needs work

Hi guys - this probably should've been split out into its own support request. I'm glad a patch came of it, in any case, but it can't go into 7.x-1.x in its current state without a deeper explanation. What does it mean to "treat 4.x submissions like 3.x submissions," for example? Are there edge cases or common cases where this would confuse a user?

Why does Webform Rules fail with it (I know it has 4.x support)?

The final patch will need to work with Webform Rules and should not expect Webform Tokens (I'm removing that dependency in Fill PDF 2).

The 7.x-1.x patch should expect Webform Tokens and act appropriately based on Webform version (it's fine to ignore it, that is, but it shouldn't break). It would be nice if it could work with Webform Rules because the default rule assumes Webform Rules.

Please don't take this as devaluing the work that went into the current patch. It's just not module-ready yet. But it's great that people with this issue have an intermediate fix available. Thanks!

wizonesolutions’s picture

Assigned: Unassigned » wizonesolutions
Status: Needs work » Fixed
wizonesolutions’s picture

Status: Fixed » Active
wizonesolutions’s picture

Status: Active » Fixed
FileSize
4.45 KB

Committed in 45b346d0e8466f9f0fcd67cfcb0fbc7705d57fbe.

wizonesolutions’s picture

Wrong patch above.

wizonesolutions’s picture

Status: Fixed » Active

Ah, whoops. This isn't committed yet. Crossed wires today. One sec.

wizonesolutions’s picture

Version: 7.x-2.x-dev » 7.x-1.x-dev
Status: Active » Patch (to be ported)
FileSize
1.91 KB

There, committed. Keep in mind this will be in 7.x-2.x-dev. The patch *should* work on 7.x-1.x, but until it gets some testing it I won't commit it.

wizonesolutions’s picture

Commit was 6451ab8cca54f03c1701ce7fef74a64f3624494c

spazfox’s picture

Awesome. The patch at #18 (applied against FillPDF 7.x-2.x-dev) is working like a charm for me with Webform 7.x-4.0-alpha6 (and no Webform Tokens module installed)!

castlemaster’s picture

Hi,

There seems to be problems with fillpdf 7.x-2.x-dev, applied path in #18 and PDF Forms API.

I tried to parse a pdf document from webform submissions without success and started debugging until I found the problem.

In
function pdf_forms_fill($filepath, $field_data, array $fill_options = array())

$fillpdf_info is not passed through, if I included it all goes as expected.

I also had to put

if (empty($path_to_pdftk)) {
$path_to_pdftk = 'pdftk';
}

somewhere in fillpdf.

Is it a work in progress or am I doing something wrong? I mean, is fillpdf 7.x-2.x-dev supposed to work with Webform 4.x?

Regards

wizonesolutions’s picture

castlemaster: 7.x-2.x-dev only works with Fill PDF Service at the moment. I think I may have forgotten to push the commit that put the patch into the module. Checking. Thanks for the prompt.

The `pdftk` issue is something that was fixed in Fill PDF 7.x-1.x but that I haven't fixed over in PDF Forms API yet. PDF Forms API is still under development, though it does work.

...yep, I had forgotten to push the commit. How embarrassing :) — it's in Git now and will be in the dev release once it regenerates (the date will change).

castlemaster’s picture

Thanks for the effort

tostinni’s picture

It seems that patch #10 works well with Fill PDF 7.x-1.9 and webform 7.x-4.x while patch #18 doesn't.
Thanks a lot for these patches.

wizonesolutions’s picture

tostinni: Correct. Patch #18 is for 7.x-2.x. It still needs to be ported to 7.x-1.x if anyone wants to.

wizonesolutions’s picture

Assigned: wizonesolutions » Unassigned
Status: Patch (to be ported) » Fixed

This has been backported to 7.x-1.x now. Open new issues for any problems.

Note: If you upgrade to Webform Tokens 7.x-1.3, you can now use Webform Rules without a conflict. However, you will need to use webform-tokens: tokens instead of webform: tokens.

If you don't use Webform Rules, then you shouldn't have to think about this. Open an issue and report a bug if you don't use Webform Rules and your tokens are affected when you update the module (but note that webform: tokens, while they work in 7.x-2.x, are not shown and will not be shown. If you're on the bleeding edge, update your Webform Tokens too :)

tostinni’s picture

Thank you.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

  • Commit 00c3661 on 7.x-1.x, 7.x-1.x-ubercartbackporttest by wizonesolutions:
    Issue #1612270: Support Webform 4.x tokens.
    
    Conflicts:
    fillpdf.admin....
  • Commit c3d02f5 on 7.x-1.x, 7.x-1.x-ubercartbackporttest by wizonesolutions:
    Issue #1612270: Avoid breaking backwards compatibility.
    
Ivan Ottinger’s picture

Issue summary: View changes

Hello guys,

I am just wondering. Should I apply the patch to the latest version of Fill PDF module? Because I am using Webforms 4.0 and can't see any tokens on mapping page. Thank you very much.

wizonesolutions’s picture

Yeah, if you are on the official release (1.9) you need to. I would try 7.x-1.x-dev, though; it should be pretty stable.

Ivan Ottinger’s picture

Thank you wizonesolutions,

I tried 7.x-1.x-dev and it works nicely with Webform 7.x-4.2. :)

sharkins17’s picture

Running Webform 7.x-4.9 and FillPDF 7.x-1.9+13-dev. Quite new to figuring this kind of thing out. What tokens am I supposed to be using? I've tried:

  • [submission:values:{component}]
  • [submission:value:{component}]
  • [webform:val-{component}]
  • [webform:{component}-value]
  • [webform-tokens:val-{component}]
  • [webform:value:{component}]
  • [webform:values:{component}]

Where {component} becomes the field key.

Liam Morland’s picture

[submission:values:?]

Remember to include parent field_keys if using fieldsets.

sharkins17’s picture

It doesn't appear to have any parent fields: https://onedrive.live.com/redir?resid=72A755A3F55D55BA!19305&authkey=!AP...

Error log shows nothing besides a notice that a PDF was generated. If I don't use a token, it puts that text in the PDF fine. But any submission/webform tokens don't seem to output anything.

For reference, I'm using the URL method under Use a URL to merge the form data into the PDF until I can get it working: https://www.drupal.org/node/1431638

SchwebDesign’s picture

I was able to get this working; I'll explain here for clarity, since "Remember to include parent field_keys if using fieldsets." above helped me get this working.

Example Webform Components:

- Customer name (Textfield)
- Physical Address (Fieldset)
-- Street (Textfield)
-- Address Line 2 (Fieldset or layoutbox)
--- City (Textfield)
--- State (Select options)
--- Zip (Textfield)

Example tokens for each that work for me:
Customer Name:

[submission:values:customer_name]

Physical Address Line 1:

[submission:values:physical_address:street_physical]

Physical Address Line 2:

[submission:values:physical_address:address_line_2_physical:city_physical] [submission:values:physical_address:address_line_2_physical:state_physical] [submission:values:physical_address:address_line_2_physical:zip_physical]

Note specific module versions installed currently which are working:
Webform: 7.x-4.9
Fillpdf: 7.x-1.9+13-dev
PDF forms API 7.x-1.x-dev
Webform Rules 7.x-1.6
Webform tokens not installed

I hope this helps someone!

Pedro Leree’s picture

Thanks SchwebDesign!

It helped me a lot! Just spent about an hour looking for this. Your post (#36) just made my day!

Gracias!