1

I have a simple Webform (https://www.drupal.org/project/webform):

  1. Single field called "name".

I also have a Profile (https://www.drupal.org/project/profile):

  1. Profile is called "basic_profile".
  2. Profile contains 2 fields: "field_name" and "field_department".

I want the default value of my Webform field "name" to be the content of the user's Basic Profile value for "field_name", but I cannot save the form because "Default value is using the following invalid tokens".

I have also tried using "[webform-authenticated-user:display-name]" which does not work.

I have tried using "[current-user:display-name]" which works but does not give me the info I want.

So how can I get the user's profile values to be used as default values for form fields? Thanks!

P.S.: The reason for this is that we are authenticating via Active Directory, and Drupal will be loading a user's profile from AD upon login. Therefore we want to leverage all data that exists in AD.

composer.json:

{
    "name": "drupal-composer/drupal-project",
    "description": "Project template for Drupal 8 projects with composer",
    "type": "project",
    "license": "GPL-2.0-or-later",
    "authors": [
        {
            "name": "",
            "role": ""
        }
    ],
    "repositories": [
        {
            "type": "composer",
            "url": "https://packages.drupal.org/8"
        }
    ],
    "require": {
        "composer/installers": "^1.2",
        "cweagans/composer-patches": "^1.6",
        "drupal-composer/drupal-scaffold": "^2.2",
        "drupal/adminimal_admin_toolbar": "^1.5",
        "drupal/adminimal_theme": "^1.3",
        "drupal/business": "^1.7",
        "drupal/business_responsive_theme": "^1.1",
        "drupal/console": "^1.0.2",
        "drupal/core": "~8.5",
        "drupal/devel": "^1.2",
        "drupal/domain": "^1.0@alpha",
        "drupal/domain_theme_switch": "^1.3",
        "drupal/eform": "1.x-dev",
        "drupal/honeypot": "^1.27",
        "drupal/insert": "^1.0",
        "drupal/maestro": "^2.1@RC",
        "drupal/mailsystem": "^4.1",
        "drupal/metatag": "^1.4",
        "drupal/module_filter": "^3.1",
        "drupal/paragraphs": "^1.2",
        "drupal/pathauto": "^1.1",
        "drupal/profile": "^1.0@RC",
        "drupal/token": "^1.3",
        "drupal/webform": "^5.0@RC",
        "drupal/workflow": "^1.0",
        "drush/drush": "^9.0.0",
        "kint-php/kint": "^2.2",
        "webflo/drupal-finder": "^1.0.0",
        "webmozart/path-util": "^2.3"
    },
    "require-dev": {
        "webflo/drupal-core-require-dev": "~8.5"
    },
    "conflict": {
        "drupal/drupal": "*"
    },
    "minimum-stability": "dev",
    "prefer-stable": true,
    "config": {
        "sort-packages": true
    },
    "autoload": {
        "classmap": [
            "scripts/composer/ScriptHandler.php"
        ]
    },
    "scripts": {
        "drupal-scaffold": "DrupalComposer\\DrupalScaffold\\Plugin::scaffold",
        "pre-install-cmd": [
            "DrupalProject\\composer\\ScriptHandler::checkComposerVersion"
        ],
        "pre-update-cmd": [
            "DrupalProject\\composer\\ScriptHandler::checkComposerVersion"
        ],
        "post-install-cmd": [
            "DrupalProject\\composer\\ScriptHandler::createRequiredFiles"
        ],
        "post-update-cmd": [
            "DrupalProject\\composer\\ScriptHandler::createRequiredFiles"
        ]
    },
    "extra": {
        "installer-paths": {
            "web/core": ["type:drupal-core"],
            "web/libraries/{$name}": ["type:drupal-library"],
            "web/modules/contrib/{$name}": ["type:drupal-module"],
            "web/profiles/contrib/{$name}": ["type:drupal-profile"],
            "web/themes/contrib/{$name}": ["type:drupal-theme"],
            "drush/contrib/{$name}": ["type:drupal-drush"]
        },
        "patches": {
            "drupal/domain": {
                "Drupal Domain New Content Type Domain Fields": "https://www.drupal.org/files/issues/2018-03-15/2953168-da-form-display-13.patch"
            }
        }
    }
}

1 Answer 1

0

According to Make profile fields avalaible as tokens, tokens for Profile fields was added, but it was added to dev 4 months ago. Since the 8.x-1.0-rc1 version was released 9 months ago, it does not have tokens.

So either switch to dev version until they release it or apply the patch provided on #22 to 8.x-1.0-rc1.

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.