Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Hi, I can't seem to get the default value for %profile[field_first_name] to work. I add the field via Administration » Configuration » Account settings » Manage Fields. Nothing shows up as the default value when viewing the form. Any suggestions?
Thanks!
Comment | File | Size | Author |
---|---|---|---|
#32 | webform_userfields.zip | 1.98 KB | hpz |
#31 | webform_userfields.zip | 2 KB | hpz |
#26 | webform_user_field_support-1023918-26.patch | 1.3 KB | shotokai |
#24 | webform_userfields.zip | 1.18 KB | guenneguez_t |
#19 | webform_userfields.zip | 1.32 KB | slbrassard |
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 CreditAttribution: skhot commentedMakes since. Thanks for the update.
Comment #3
quicksketchMarked #1134268: Not working %profile[key] for "default value" as duplicate.
Comment #4
cartagena CreditAttribution: cartagena commentedThank you.
Comment #5
chaloum CreditAttribution: 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 CreditAttribution: Nil Gravitas commentedSubscribing! I really want this to happen.
Comment #9
bjaxelsen CreditAttribution: bjaxelsen commentedI've implemented this in a utility module. It might be ported into the webform module:
Comment #10
Theo CreditAttribution: Theo commentedThanks bjaxelsen! That code worked great.
Comment #11
mariagwyn CreditAttribution: 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 CreditAttribution: Buliwyfa commentedThe hook to support "Field fields" is really nice and +1 to be ported to webform realease.
Thanks ;D
Comment #13
micke793 CreditAttribution: 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 CreditAttribution: 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 CreditAttribution: 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 CreditAttribution: 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 CreditAttribution: 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 CreditAttribution: TimelessDomain commentedComment #19
slbrassard CreditAttribution: 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 CreditAttribution: 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 CreditAttribution: 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 CreditAttribution: 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 CreditAttribution: guenneguez_t commentedRemplace the version of slbrassard if user field is not set.
Thanks
Thomas
Comment #25
flightrisk CreditAttribution: 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 CreditAttribution: 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 CreditAttribution: shotokai commentedComment #28
Herr Lehmann CreditAttribution: Herr Lehmann commentedPatch from #26 works for me (sofar) - thanks!
Comment #29
flightrisk CreditAttribution: 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
$account
as explicit reference as you hopefully never try to modify the object here ... ;)Code style: missing space between
$field
and $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 CreditAttribution: 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 CreditAttribution: 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 CreditAttribution: xcafebabe commentedThanks for this improvement!
Comment #36
rolandu CreditAttribution: 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 CreditAttribution: 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!