# Can topic templates have javascript?

**URL:** https://meta.discourse.org/t/can-topic-templates-have-javascript/146192
**Category:** Support
**Created:** [March 30, 2020, 7:49pm UTC](https://meta.discourse.org/t/can-topic-templates-have-javascript/146192 "2020-03-30T19:49:18Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![xceph](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/xceph/32/174216_2.png) [@xceph](https://meta.discourse.org/u/xceph)
#### Post date: [March 30, 2020, 7:49pm UTC](https://meta.discourse.org/t/can-topic-templates-have-javascript/146192/1 "2020-03-30T19:49:18Z")

</div>

Id like to create templates which have required fields, ideally these would be via dropdown selection boxes.

For example, if a field required the user to list their favourite animal they could choose from a box containing: “Dog, Cat, or Gargoyle”, I’d really like to provide options rather than have free form entry. Is this or anything similar possible?

---

<div class="post-metadata">

### Author: ![pfaffman](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pfaffman/32/120154_2.png) [@pfaffman](https://meta.discourse.org/u/pfaffman)
#### Post date: [March 30, 2020, 7:59pm UTC](https://meta.discourse.org/t/can-topic-templates-have-javascript/146192/2 "2020-03-30T19:59:33Z")

</div>

If you use tags you won’t have to write a plugin that will be likely to break every time templates change upstream. I recommend that you spend an hour or so trying that before starting to write a plugin.

You can have a look at [discourse-topic-previews-sidecar/plugin.rb at master · merefield/discourse-topic-previews-sidecar · GitHub](https://github.com/paviliondev/discourse-topic-previews/blob/master/plugin.rb) for an example of creating Topic Custom Fields.

---

<div class="post-metadata">

### Author: ![Falco](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/falco/32/179432_2.png) [@Falco](https://meta.discourse.org/u/Falco)
#### Post date: [March 30, 2020, 9:22pm UTC](https://meta.discourse.org/t/can-topic-templates-have-javascript/146192/3 "2020-03-30T21:22:44Z")

</div>

> [@xceph](#):
>
> I’d really like to provide options rather than have free form entry. Is this or anything similar possible?

Discourse is, at heart, a free form discussion software.

If what you really need is a strict form, you may have better results using a more appropriate software. You could embed solutions like Google Forms and Typeform to ease the transition for your users, like this example:

https://showroom.typeform.com/to/fhFJNQ?typeform-embed=embed-widget

---

<div class="post-metadata">

### Author: ![xceph](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/xceph/32/174216_2.png) [@xceph](https://meta.discourse.org/u/xceph)
#### Post date: [March 30, 2020, 9:33pm UTC](https://meta.discourse.org/t/can-topic-templates-have-javascript/146192/4 "2020-03-30T21:33:03Z")

</div>

Thanks, I think my wording was bad, still want free form discussion but certain things are required to initiate that. I think using the tags and templates will be enough to make it work​😀

---

<div class="post-metadata">

### Author: ![Falco](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/falco/32/179432_2.png) [@Falco](https://meta.discourse.org/u/Falco)
#### Post date: [October 16, 2023, 7:22pm UTC](https://meta.discourse.org/t/can-topic-templates-have-javascript/146192/5 "2023-10-16T19:22:53Z")

</div>

This is now possible thanks to [Introducing Form Templates](https://meta.discourse.org/t/introducing-experimental-form-templates/278631)

---

<div class="post-metadata">

### Author: ![Falco](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/falco/32/179432_2.png) [@Falco](https://meta.discourse.org/u/Falco)
#### Post date: [October 16, 2023, 7:22pm UTC](https://meta.discourse.org/t/can-topic-templates-have-javascript/146192/6 "2023-10-16T19:22:56Z")

</div>


