# Summary

This module enables to use tokens as field default values. The main discussion: #1070878: Allow tokens to be used in the default value of a field

# Project URL

https://www.drupal.org/project/field_default_token

# Where is the code?

?

# Estimated completion date

?

# Dependencies

?

# Who's doing the port?

?

# What help do they need?

?

# D8 roadmap

#2660946: [meta] Field default token D8 port

# Background and reference information

?

Comments

darol100 created an issue. See original summary.

mohit_aghera’s picture

Assigned: Unassigned » mohit_aghera

I'll be working on this port.
Will post repository URL soon.

juliencarnot’s picture

Hi @mohit_aghera ,
Did you start the port? I'd be happy to help testing!

mohit_aghera’s picture

@juliencarnot
Yes, i have started but haven't done any significant progress.
Will update you once it is good to test.

Repo URL : https://github.com/mohit-rocks/field_default_token
P.S. It isn't finished yet.

stefan.r’s picture

@tstoeckler is also working on this at https://github.com/tstoeckler/field_default_token

tstoeckler’s picture

@mohit_aghera Based on your repo, I finished the D8 port and just posted a patch at #2660946: [meta] Field default token D8 port.

mohit_aghera’s picture

@tstoeckler
Thank you for picking up. Will try it out soon.

maxilein’s picture

Is the dev in some testable state? Or should I wait before I try it? Thanks

tstoeckler’s picture

The newly created dev should be fully functional. There are known issues with some field types (Entity Reference and E-Mail are known at this point), but other than that there should be no problems. So please test if you can.

badrange’s picture

Is the 8.x branch in this project identical to the github repo mentioned above? Would be nice to see a release of this module!

mohit_aghera’s picture

@badrange
I have dropped a message to maintainer "maximpodorov" , let's see what he suggests.

toamit’s picture

I tested dev version on the project page (8.x-1.x-dev updated 28 Oct 2016 at 17:34 UTC)
It works!

mmjvb’s picture

Status: Active » Needs work
carnerik’s picture

I just tried the dev version and it's not really working for me. I'm using Drupal 8.5.3 on my localhost.

I'm not a programmer, so I can only give feedback on the front-end results, but maybe it's helpful?

  1. I put the token [node:title] in the "Token for default value" field on a taxonomy entity reference field and was able to save the field settings. However, when I went back to the settings form, the token was gone. The token was also missing on the add content form.
  2. I tried putting the token in both the "Token for default value" field and the regular default field at the same time. The field settings form saved. On the add content form, the value for the field was "[node:title]", but it didn't resolve when I saved the new content. Instead, it added "[node:title]" as a taxonomy term. Going back to the field settings form, the token had once again disappeared from the "Token for default value" field.
  3. Next, I tried [node:field_number] (an integer field) as the default for the body field. The body field was blank on the add content form, but the token resolved correctly when I saved/viewed the new content. The default value field on the body field settings page was also blank when I checked it after, but even after saving the settings again--with an apparently blank default field--the token still resolved when I created another new piece of content.
  4. When I used the [current-page:title] token as the default of the body field, the token resolved on the add content form to "Create (name of content type)". When I checked the body field settings form, the default value changed to "Body".
  5. The [node:title] token didn't work at all as the body default value; it disappeared from the field settings form, didn't appear on the add content form, and didn't resolve when I saved/viewed the new content.
mmjvb’s picture

@carnerik Suggest to move your feedback to the issue queue of the project itself. This issue is for the port to D8. Bug reports & support requests should be posted to the project, NOT this issue.

carnerik’s picture

Will do. Is there a way to delete comments?

mmjvb’s picture

No, but you could replace it with the link to your issue.
When you do, use format [#"issue_id"@] where "issue_id" = sequence number of issue

chuck_theobald’s picture

Is this project still progressing? A similar project, Field Token Value, has a 1.0 release for D8: 8.x-1.0 Stable release covered by the Drupal Security Team released 24 August 2017.

avpaderno’s picture

Assigned: mohit_aghera » Unassigned