Closed (fixed)
Project:
Token
Version:
7.x-1.x-dev
Component:
Code
Priority:
Major
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
9 Jan 2011 at 02:27 UTC
Updated:
26 Jan 2011 at 13:30 UTC
Jump to comment: Most recent file
The #element_validate fails to validate the valid [current-user:roles] placeholder added by Google Analytics.
Error message is The Custom variable value #1 is using the following invalid tokens: [current-user:roles].
I'm using this form code:
$form['googleanalytics_custom_var']['slots'][$i]['value'] = array(
'#default_value' => !empty($googleanalytics_custom_vars['slots'][$i]['value']) ? $googleanalytics_custom_vars['slots'][$i]['value'] : '',
'#description' => t('The custom variable value. You may use tokens in this field.'),
'#title' => t('Custom variable value #@slot', array('@slot' => $i)),
'#title_display' => 'invisible',
'#type' => 'textfield',
'#element_validate' => array('token_element_validate_token_context'),
'#token_types' => array('all'),
);
| Comment | File | Size | Author |
|---|---|---|---|
| #6 | 1020100-token-validate-all.patch | 3.21 KB | dave reid |
Comments
Comment #1
hass commentedComment #2
dave reidUse the latest 7.x-1.x-dev of token please.
Comment #3
hass commentedThere are no newer versions... I have installed both DEVs tonight!
Comment #4
hass commentedhell, it is fixed... must have been tooooo late tonight.
Comment #5
hass commentedFound user tokens are still not validating. I have also tried
'#token_types' => 'all', but this gave me some array errors. Message is "The Custom variable value #2 is using the following invalid tokens: [user:picture]."As I'm using token_tree with 'all' and it also shows me the 'user' tokens... so users may select them.
Comment #6
dave reidI never tried the validation using '#token_types' => array('all') before. But looking over the GA token_replace() code it only can provide node tokens + global token types. So the use of array('all') in the form field is incorrect. It really should be array('node') so that should be fixed upstream in the GA module. Regardless, there still is a problem with the validation.
Comment #7
dave reidFollow-up fixed filed in GA with #609892: Multiple custom variables.
Comment #8
dave reidCommitted #6 to 7.x-1.x.
http://drupal.org/cvs?commit=479634
Comment #9
dave reidFixed on 6.x-1.x as well.
http://drupal.org/cvs?commit=479658
Comment #10
hass commentedAre we able to make this consistent, please? If we use token_types in form element validation with array('all') i wish we also use an array in token_tree form element and not a string. I'd like to use 'all' in the token replece, too. Otherwise an 'all' in token_tree makes no sense to me.
Comment #11
dave reidUsing all does not work with token replacement. It never has. It's a display only option (used on the admin/help/token page to list all tokens on the site). If it doesn't make any sense to use (and since I've been trying to point out it's usage is wrong), then change it in your code to not use array('all').