I am creating a custom module webform3rdparty integration to icontact .Using my module create an extra field in weform field to add icontact field(mapping purpose).I want to use token replacement patterns in my field.How to call these replacepatterns in my custom module.
1 Answer
I think you need these hooks:
- hook_token_info() - this hook will allow you to define empty placeholders. Define a few placeholders which you want to make available to the webform.
- hook_tokens() - corresponding to the plkaceholders you have defined, pass in appropriate stuff and define a replacement pattern for each placeholders you have defined in your earlier hook_implementation.
- Finally, while rendering user submitted value, apply token_replace() function to replace the placeholders entered by user with appropriate values.
UPDATE:
Got you. Have a look at this function _webform_filter_values(). This funciton is responsible for replacement of webform tokens. you can use this funciton in your code, pass in the stuffs you want to replace and the node and submiccions object and have the value replaced.
It will be impossible for me to give you exact direction, as i am not familiar with what you are doing. But i can give you a general idea. Token replacement often happens at the output stage. So it is more concerned with output. So mostly, you need to apply this to your code which displays/prints/uses the webform submission result of your field.
Say you create a webform field. I as an end user, enter a string to it which contains this: %post[key]. Now your submit handler code will need to use the said function. When you pass the input i entered through that function, my %post[key] is replaced by appropriate value.
-
I want to call replacepatterns used in webforms in my site.ie,I would like to be able to use tokens %post[key] Oct 9, 2013 at 8:09
-
-
Thank you neo for your detailed reply.But still i am confused how to implement for that particular field created by my module. Oct 9, 2013 at 9:23
-
I will not be able to provide you with detailed code, but just updated my answer as the last shot to help you grab the concept. hope that helps.– NeoOct 9, 2013 at 9:33