Closed (fixed)
Project:
Webform
Version:
7.x-4.x-dev
Component:
Miscellaneous
Priority:
Normal
Category:
Support request
Assigned:
Reporter:
Created:
13 Jan 2012 at 14:16 UTC
Updated:
1 Jul 2014 at 15:12 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #1
quicksketchThis isn't possible in Webform currently.
Support for normal user tokens will probably be added in #1023918: Add support for user Field module fields e.g. %profile[field_name].
Full support for all tokens using the token module will have to wait until #1001798: Rewrite token replacement system to use D7 tokens.
For now, the only option to get Profile2 tokens in your fields is to use hook_form_alter() and inject the profile values manually.
Comment #2
gopisundar commentedthanks for replying. i will try to do with what u said..
Comment #3
gopisundar commented@quicksketch
i have done this with user account fields. wrote a custom module and it worked. thanks for your informations.
Comment #4
quicksketchComment #5
gopisundar commented@quicksketch
I have installed 3.16 and have checked for unique. Now its working fine and you have added lots of changes. Thanks a lot:) Drupal is best. I am working on 3.16. if i have any clarifications i will post a new issue. thanks..
Comment #6
jp.stacey commentedFor reference, as far as I can tell, the full tokenization of webforms in #1001798: Rewrite token replacement system to use D7 tokens is only available in the 7.x-4.x branch - can anyone confirm? I'm switching this ticket to that branch so people googling for "profile2 webform token" will realise.
My own experience is that I couldn't get this working, even with the 3.x dev branch; when I switched to 4.0-alpha3, it started working; not only that, but my existing "old-style" tokens were rewritten by a database update to follow "standard" token syntax.
Anyway, it might be good if 1001798 were also changed to show that it was only fixed on 4.x, if that's the case (comment 99 seems to suggest yes.)
Comment #7
simone960 commentedI wonder how to print the profile values? I use "print_r($node);" to print node's values in node template. What about profile?
Besides, I tried to use Devel module to view variables on a profile page (e.g. /user/uid ), though I can see the values in "Render" mode, but seems pretty complex. If I would to print e.g. field_mobile, how should I write?
$profile->profile_main["view"]["profile2"][2]["field_mobile"].......??Please advise. Appreciate if someone can post a tested hook_form_alter code for my reference. Still new to programming. Thanks.
Comment #8
DrCord commentedThis Drupal 7 tested hook_form_alter loads up a profile2 value, puts the current value into the form, and upon submission saves it back to the profile2 field. Hope this helps someone needing more of an example
Comment #9
danchadwick commentedA couple of things to be aware of.
1) Your submit handler will execute for buttons other than the Submit Evaluation button (e.g. Save Draft, Next Page, etc).
2) If webform changes how it sets the submit handlers (e.g. moving them to the buttons), your HOOK_form_alter will break.
3) Finding the webform by it's node ID ties your code very tightly to the database. If you migrate to a new database, your NID's will change. Instead, you might identify the form by looking at the form elements that are in it and distinguishing it from others that way.
Comment #10
DrCord commented@DanChadwick - I find it interesting and lame that the request for an example to help someone has been on this thread for a year and you didn't post one, but as soon as I do you trash it. I understand giving feedback to make a post more useful, but the point of the example wasn't to write perfect code for every situation for 70 years in the future, it was to give a quick working example of how to load a profile field and save it...
Comment #11
danchadwick commented@DrCord - I was helping you and others following your code, not trashing your code. Since you find it lame, I'll stop.
Comment #12
DrCord commented@danChadwick - I don't find it lame to help others, that was my intention with posting the code originally. What I do find lame is that people, especially from the open source community, are very ready to poke holes in someone else's stuff but don't post themselves...For example, why didn't you put up an example sooner if you were monitoring this question thread and were ready to respond in less than 8 hours? Seems like you should have made a post on that thread a long time ago, in which case I wouldn't have had to figure that out for myself...Which is why I posted the code, to prevent others from having to start from scratch...
Comment #13
danchadwick commented@DrCord - Code review / critique is a cornerstone of software quality engineering. Please, please do poke holes / trash my, quicksketch's, fenstrat, Liam Morland, or any of the other couple dozen committers to webform. I'm sure there are literally thousands of places it could be improved. Constructive criticism (i.e. suggesting a better way) and non-constructive criticism (i.e. pointing out deficiencies without offering a solution) are both highly welcome. Patches are best.
You seem to have lots of energy. Webform desperately needs people such as you to contribute to the issue queue. I try to use the time that I can commit (pun intended) to this project to apply RTBC patches, sometimes review and then apply Needs Review patches, and sometimes writing patches (of no benefit to me) for others that I see are contributing to the issue queue (e.g. Liam Morland). If I see a support request and happen to be familiar with the code, I sometimes offer suggestions, but really my time is better spent improving the code base (since there are few committers and many who could answer questions in the issue queue).
You have made assumptions about my involvement, its intensity and its timeline which are incorrect. Since you asked, I was not following the issue queue a year ago (and I'm tempted to stop now). You posted to a closed issue. I only look at open issues. There is the concept of a "ladder" in contributing to Drupal. You climb the ladder (starting at, say, improving documentation) to the highest rung at which you can competently contribute. There are fewer people at each higher rung. We need more people at the lower rungs, and really the higher rungs too, particularly for D8.
No one, quicksketch included, is paid to write this module. That quicksketch replied two years ago with a researched, thoughtful reply, is a testament to his fucking awesomeness. Want to be humbled? Look at his profile. I'm no quicksketch, but my contribution speaks for itself.