Hi there - I'm the maintainer of Webform Tokens and noticed that you have token support (data selectors) in this module. I was wondering if you'd be interested in depending on Webform Tokens and contributing any necessary code to that in the 7.x version.

It would make sense to consolidate all token generation and consumption functions for webforms and submissions being used by external modules (since Webform still uses its own) to that module. Hopefully, it will hit critical mass and be incorporated into Webform core.

Anyway, just an idea. Wasn't sure if you knew about the module so thought I'd throw it out there.

Comments

emptyvoid’s picture

It would appear the module maintainer is either too busy or not into collaboration. I'd guess he's just too busy to respond.

Great idea though as I'm finding the D7 release not all that useful and I may just write my own custom module with a hook_form_alter() to validate and or transform submissions data.

stborchert’s picture

Sorry about not responding. I can't remember exactly why I did not had a deeper look into Webform tokens but it could be because it was highly unstable at the time ...
It would be grate if you could provide a patch with the integration.

wizonesolutions’s picture

OK, looks like I will be contributing something towards this because I just discovered that Webform Rules breaks filling in PDFs with Webform submissions (I think we are clashing on the webform namespace). Step 1 for me is to change the Webform Rules token namespace to satisfy the immediate client need. I'll post the patch, though I can't imagine that's in your interest to commit...still, maybe it'll spark conversation.

Next step would be to tell Webform Rules to use Webform Tokens tokens if available (otherwise fall back to its own, which will be re-namespaced) and to write the appropriate Rules integration (and calling of token_replace for the same.

Gradually the native support can be phased out, or perhaps this could go in a new branch...your call...just suggestions.

wizonesolutions’s picture

OK, I actually did the whole thing. Rules now replaces the tokens properly, and Webform Rules has a hard dependency on Webform Tokens.

I had to change the data structure to conform to what Webform Tokens expects. You're welcome to submit a patch changing said data structure to Webform Tokens...but I think that the structure that webform_get_submission uses is a pretty good one to bank on, and that's why we went with it in Webform Tokens (see Fill PDF's token_replace for webform for an example of another consumer).

This should definitely go in a new branch if you're game for that so that it doesn't mess up people using Webform Rules tokens. Or you could write hook_token_info_alter() and hook_tokens_alter() if backward compatibility is big...but it seems like a lot of work for little gain. I think someone could contribute that patch if they needed the old token structure in the new branch.

Potential issues that I can see:

  1. I noticed you had some formatting code in your version of token replacement. I didn't take time to understand that, but if you can tell me what that was about, maybe I or Liam can put it into Webform Tokens.
  2. You did some data massaging to turn the $submission object into field-name-indexed arrays. I'm guessing you did this to make rules that use the $data object more portable. Unfortunately, that structure was making Webform Tokens's token replacement fail, so I moved those to a webform_rules property on the $data object. So people using PHP code will have to use that in order to have portable configuration...for now.

Hope this helps! And I eagerly look forward to having a second module using Webform Tokens :) - keep in touch...when we work this out I can mention Webform Rules on the WT project page.

liam morland’s picture

Thanks, Kevin. I'm all for this from my perspective as the other maintainer of Webform Tokens.

stborchert’s picture

Status: Active » Needs work

Hi.
Thanks for your work on this. Unfortunately it doesn't really match my plans on integrating (or better: "on collaborating with") other modules. In my opinion there is no need for a hard dependency to Webform Tokens as the Token support itself is optional in Webform Rules (at least in D6, with D7 you can't decide on not using tokens ;) ).

Goal: users who'd like to use more tokens than that provided by can do so by installing Webform Tokens.
So we need to find a way on how to append (!) the tokens from Webform Tokens in a more generic way to the ones provided by Webform Rules. I propose, changing the namespace of tokens provided by Webform Rules to "webform-submission" so there will be no name-clash if using both modules.

Thoughts?

wizonesolutions’s picture

Yeah, re-namespacing yours to webform-submission would also do the trick. Then you could implement webform in hook_rules_data_info() if module_exists('webform_tokens') is true, as well as the other integration points I added/modified.

stborchert’s picture

Status: Needs work » Needs review

Here is a patch that changes the namespace, the data structure and integrates tokens provided by Webform tokens (if enabled).
Please test if this works (without and with Webform tokens. If all works fine, I'll need to update the readme according to the new structure and create a new release.

stborchert’s picture

StatusFileSize
new5.78 KB

Uhm, forgot the patch :/

wizonesolutions’s picture

So coming back around to this...I think your approach is fine. Also, note that the new Webform 4.x branch has its own Token implementation. Fill PDF is planning to detect Webform version and still support Webform 3.x (which has none) via Webform Tokens and use native Webform tokens for 4.x (perhaps initially providing an integration layer for tokens Webform might not have implemented yet, and deprecating it once they do).

Anyway, about to apply this patch again so will RTBC it if it doesn't conflict with Webform Tokens.

wizonesolutions’s picture

Status: Needs review » Reviewed & tested by the community

This works fine; I say commit it if you agree.

stborchert’s picture

Status: Reviewed & tested by the community » Needs work

Migration from old token types to the new ones is missing in the patch.

wizonesolutions’s picture

What do you mean? You merge them, so yours will continue working. Migration can be manual, but the patch won't break the tokens.

If you mean the Webform 4.x tokens, then I think that's a separate issue to tackle. So let me know.

wizonesolutions’s picture

Status: Needs work » Closed (won't fix)
nessunluogo’s picture

I have installed current stable releases of WebForm Rules module (7.x-1.6).
Will #9 patch work here or i have to switch to -dev?

Thanks!

wizonesolutions’s picture

You shouldn't need this anymore with the latest FillPDF and Webform Tokens versions. it's all fixed.