The default value tokens (such as %profile[profile_addr1] ) are showing in webform fields for authenticated users when I would prefer there to be a blank. Is there anything I can do to stop it happening? It started to happen a few version updates ago.
Thanks

CommentFileSizeAuthor
#10 CaminoScreenSnapz001.jpg52.67 KBjohnla
#8 screenshot.jpg68.71 KBtomsm
#7 screenshot.JPG0 bytestomsm

Comments

quicksketch’s picture

I'm not sure what you're requesting. If you want the field blank, why not just empty the field default value out entirely?

class47’s picture

Sorry not to be clear.
I've put the tokens in the webform fields as part of setting up the form. However, they still show through as tokens (such as %profile[profile_addr1]) on the form as viewed by the user in those fields where the profile does not have an entry. Where the profile does have an entry, the form shows it correctly. The blanks are also sent in token form by email.

quicksketch’s picture

Ah, okay now I understand. So if the user has not set an profile_add1 value then the token still shows up in the textfield? Can you confirm this still occurs in the 2.9 version? The 2.8 version didn't handle profile values correctly at all, which is when this probably cropped up (see #604958: %profile and %server default values broken for more info on that).

class47’s picture

Yes, the problem still occurs with version 2.9.

daengo’s picture

I just noticed this too when switching to 2.9. I can use most of the tokens but can't use any of the %server tokens, for example, %server[HTTP_USER_AGENT]. It just repeats %server[HTTP_USER_AGENT] back to me when I view the form.

ScottyM-2’s picture

I just updated to 2.9 and I am experiencing the same issue with the %profile tokens when browsing the site as an anonymous user, or as a user who does not have a value for the specific token.

tomsm’s picture

StatusFileSize
new0 bytes

I have the issue too. When an anonymous user opens the webform, he sees all %profile tokens. The %useremail and the %profile select list tokens are not shown. Also see screenshot for more information.

tomsm’s picture

StatusFileSize
new68.71 KB

Sorry, screenshot was missing...

lenart’s picture

Same here. Drupal 5.20 and updated Webform to 2.9. When logged in %profile tokens work as expected. When browsing the site anonymously the fields are filled with %profile[profile_xxx] instead of blank values.

johnla’s picture

StatusFileSize
new52.67 KB

Well, in the token values description it states that only "Authorized Users" can use these tokens:

* %username
* %useremail
* %session[key]
* %post[key]
* %request[key]
* %cookie[key]
* %server[key]
* %profile[key]

I'm trying to figure out if there's a way to allow some of the these tokens to be used by anonymous users.

lenart’s picture

I've found this fix does the trick for me - http://drupal.org/node/604958#comment-2166032

Now fields for registered users are pre-filled with correct values and blank for anonymous users.

diabolical’s picture

I'm having the same problem... basics like REQUEST_URI and HTTP_USER_AGENT server keys don't retrieve the actual values, even when I'm logged in as the admin (hence authorized)... any ideas?

jdwfly’s picture

I've got the same problem. Tokens are not being replaced with 2.9. Personally I am trying to use %server[REQUEST_URI] and it won't even show for uid 1.

jdwfly’s picture

I added $_server to the unsafe part of the array and this makes it work as advertised.

  $special_tokens = array(
    'safe' => array(
      '%get' => $_GET,
    ),
    'unsafe' => array(
      '%cookie' => $_COOKIE,
      '%session' => $_SESSION,
      '%post' => $_POST,
      '%request' => $_REQUEST,
+    '%server' => $_SERVER,
    ),
  );

Just a few lines down there is this...

    // Doesn't really belong here with user things, but works.
    $special_tokens['unsafe']['%server'] = $_SERVER;

It is inside of an if statement and it apparently is not working. I suggest moving it to where the rest of the vars are being set as candidates. The only problem I see is this may possibly introduce problems with caching tokens?

diabolical’s picture

Worked like a charm. Thanks jdwfly!

clivesj’s picture

I'm trying hard to be able to use %session for default values.
Anyone knows how to do it?
If i enter default value %session['my_module']['my_value'] the token is not replaced.
Thanks for the help.

quicksketch’s picture

Status: Active » Closed (duplicate)
UNarmed’s picture

I am having the same issue, hope the fixes mentioned above do the trick =]