Closed (fixed)
Project:
Webform
Version:
7.x-3.x-dev
Component:
Code
Priority:
Normal
Category:
Feature request
Assigned:
Unassigned
Reporter:
Created:
12 Jan 2011 at 05:41 UTC
Updated:
27 Mar 2013 at 18:30 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #1
quicksketchThese fields do not work because they are not actually supported (yet). Those fields are not Profile fields, they are Field fields (confusing I know). Webform currently only supports the fields added by Profile module (which I wouldn't really recommend over the Field module fields that you're already using). I'm moving this to a feature request because it would make sense to support such fields.
Note that this problem would be solved a separate way through #1001798: Rewrite token replacement system to use D7 tokens.
Comment #2
skhot commentedMakes since. Thanks for the update.
Comment #3
quicksketchMarked #1134268: Not working %profile[key] for "default value" as duplicate.
Comment #4
cartagena commentedThank you.
Comment #5
chaloum commentedQuicksketch
Just trying to understand your post(#1) are you saying we should not use the profile module, which is think is Profile2 but instead use the core fields method as described by skhot?
thanks
Comment #6
quicksketch@chaloum: The "Profile" module is still shipped with Drupal 7 but it is impossible to enable because its use is deprecated. The only way to use Profile module in Drupal 7 is to have the module enabled when you upgrade from Drupal 6 (or manually enable it in the database).
Profile module would put things directly in the $user object like this:
Field module on the other hand puts them in the $user object like this:
Because our tokens do not support nesting (see #1037524: Support array-format tokens in [current-page:query:x] tokens), you can't use a token like %profile[field_first_name][0][und] (which is what this token would be usually). It'd be nice to make these tokens significantly simpler, or to implement #1001798: Rewrite token replacement system to use D7 tokens which would make tokens more complicated but at least consistent with the rest of Drupal.
Comment #7
miro_dietikerSubscribing
Comment #8
Nil Gravitas commentedSubscribing! I really want this to happen.
Comment #9
bjaxelsen commentedI've implemented this in a utility module. It might be ported into the webform module:
Comment #10
Theo commentedThanks bjaxelsen! That code worked great.
Comment #11
mariagwyn commentedWould really like this as well, happy to test. to be clear though, I do not have any profile fields (new site, not use) but only "Field fields" as quicksketch labelled them above.
Maria
Comment #12
Buliwyfa commentedThe hook to support "Field fields" is really nice and +1 to be ported to webform realease.
Thanks ;D
Comment #13
micke793 commentedI have the same problem as skhot has, did bjaxelsen code fix that problem?
If it does, how do I implement that code?
//Micke
Comment #14
shotokai commented@micke793 - the code does fix the issue and let you pull 'field fields' from the user entity into your webform.
To use it you can follow these steps if you want to learn the basics of module development: http://drupal.org/node/1074360 or you can use the attached. Worked for me. Just install like any other module - although you might want to stick it in a 'custom' directory so that you know this a not a proper contributed module in the future...
@bjaxelsen - thanks for the code. final piece in a puzzle for me..
Comment #15
e-weavers commentedHi,
I am getting this error on the form page:
Line 21: $field['#default_value'] = $account->{$extract[1][0]}['und'][0]['value'];
Please Help!
Comment #16
shadowdknight commentedDoes this works with Profile2?
How do I include this in the submission email eg:%profile[field_user_ref] ?
Please help!
Thanks
Comment #17
TimelessDomain commented#14 worked great for core profile fields (did not try profile2 yet)
actually. it does work but i am getting the same error as #15
Comment #18
TimelessDomain commentedComment #19
slbrassard commented@shotokai: Thank you for the code. It was very helpful. I found that profile field tokens inside of fieldsets were not being handled so I modified your code a bit to handle that case. Posting it here in case it's helpful to someone else.
Comment #20
Polyspiral commentedWill the above code be out into the next release of Webform?
Thanks
Comment #21
quicksketchNot in its current state, since features need to be written as patches in order to be reviewed and included in the project.
Comment #22
chaloum commentedDesperately need this to become a reality as username tends to be meaningless to survey administrators, and having to get people the type in their name when its already in the system just generates complaints.
Is there a workaround outtside of the above code??
Comment #23
flightrisk commentedI've read through most of the forum and all the release notes for webform and still have no idea:
1. What is the current state of getting at all the tokens from the tokens module (in particular the user and current user tokens)
2. I have the version from July. Will I have to upgrade? What is the upgrade process?
Comment #24
guenneguez_t commentedRemplace the version of slbrassard if user field is not set.
Thanks
Thomas
Comment #25
flightrisk commentedIs this going to be a patch and then included in a release? Can anyone submit some official patch so we can get this inside the module and not have to have yet another module?
Comment #26
shotokai commentedThis is the first patch I've submitted - so I've tried to follow the rules, but I'm sure I've missed something...
The patch is against 7.x-3.9-hotfix
Comment #27
shotokai commentedComment #28
herr lehmann commentedPatch from #26 works for me (sofar) - thanks!
Comment #29
flightrisk commentedHi shotokai, can you provide a little documentation? After patching, how do I input the user fields? What is the format, or will they now display in a list for me to select?
Comment #30
stborchertCode review (without functional test):
Code style: missing space between
$form['submitted'],and$account.No need to pass
$accountas explicit reference as you hopefully never try to modify the object here ... ;)Code style: missing space between
$fieldand $account.Please do *not* use
['und'][0]for fields. Never.Use field_get_items() instead.
Btw.: patches are made against HEAD (7.x-3.x-dev).
2nd btw.: thanks for helping with this issue!
Comment #31
hpz commentedHere is my version of the webform_userfields module, which also replaces multiple occurences of a '%profile[key]' token whithin one webform default value.
Comment #32
hpz commentedHad to fix it. This one is better.
Comment #33
quicksketchUse the Webform 7.x-4.0-alpha1 release available on the project page, which includes #1001798: Rewrite token replacement system to use D7 tokens. Other than that it is identical to the current 3.x branch.
Comment #34
xcafebabe commentedThanks for this improvement!
Comment #36
rolandu commentedThis change has now been in the 4.0-alpha-branch for almost a year, could this be pushed to the 3.x-branch? I believe a lot of people need it and have to use the alpha version because of this. (At least several of my sites are doing that.)
Comment #37
kuydigital commentedMy site has a lot of forms and I'm afraid to remove the module and install 4.0-alpha-branch. Is it still possible to push this to the 3.x-branch as a recommended update in Drupal 7?
Thanks!