Can topic templates have javascript?

AI-generated summary

The discussion revolves around whether topic templates in Discourse can include JavaScript or structured input fields like dropdowns. xceph wants to enforce required fields with predefined options (e.g., favorite animal) rather than free-form text. pfaffman suggests using tags and custom fields as a more stable solution, referencing a plugin example. Falco notes that Discourse is primarily designed for free-form discussions and recommends external tools like Google Forms or Typeform for strict forms, but also highlights that experimental form templates are now available via meta.discourse.org. xceph clarifies their intent and agrees that tags and templates may suffice. Falco confirms that form templates are now possible, addressing the original question.

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?

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 for an example of creating Topic Custom Fields.

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:

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​:grinning_face:

This is now possible thanks to Introducing Form Templates