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.
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.
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.