1

Is there a way I could display a token (for exmaple user ID) as a default field content to a content type?

Id like to display a node form to users /node/add/content type

when a user goes to that page the field "name" automatically displays the user id.

name: [user:uid] - something like that

Is it possible, If so, how can I achieve this?

Thanks

2 Answers 2

0

Do you want it to be editable or not?

Either way, its going to take a small custom module with hook_form_alter or hook_form_FORM_ID_alter if you want to target a specific form.

If you want it editable:

http://api.drupal.org/api/drupal/developer!topics!forms_api_reference.html/7#default_value

If you want it set at a value:

http://api.drupal.org/api/drupal/developer!topics!forms_api_reference.html/7#value

Start with downloading and enabling devel and a small module with just this to get a list of all the form elements on a page:

function YOUR_MODULE_NAME_form_alter(&$form, &$form_state, $form_id) {
  dsm($form_id);  // print form ID to messages
  dsm($form);  // pretty print array using Krumo to messages
}
0

Unfortunately there isn't a module for that.

Check these links though; people posted some patches but I haven't tried any of them.

http://drupal.org/node/1070878

http://drupal.org/node/700230

http://drupal.org/node/700230

http://drupal.org/node/1308564

On the other hand, I think you can use hook_form_alter() to set the default field value on that node add form.

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.