1

Say I'm creating content into a text field. Instead of inserting text by typing into text field, how could select text from a drop down list to pre populate the text field?

1

2 Answers 2

1

I would suggest you create a content type called "Text Templates". Then add a reference to this content type in the content type that you are using.

In hook_node_submit you can get the value from the body fields of the Text Template node using the node-reference and then pre-populate in your current node.

If you want the body to be filled during the node edition then you will have to write an ajax call to fetch the body based on the drop-down value and fill it in the body.

1

Have a look at this module and see if it does what you need

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

Your Answer

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

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