ganncamp reports dissatisfaction with the default styling of posts generated by form templates, noting that the output includes excessive whitespace and header formatting that does not align with their expectations. They propose adding an answer-styling attribute to form inputs to allow for more control over the presentation. ganncamp further shares feedback from their team, who desire a formatting toolbar and alternative layouts, such as placing fields in a box at the top or side of the post.
manuel suggests using standard category topic templates or the Discourse Templates plugin to address these needs. However, ganncamp clarifies that standard templates do not ensure data compliance and that the request specifically concerns the visual presentation of form-gathered data, not template structure. Jayne_ivana supports the feature request, adding a suggestion to include standard formatting tools for text inputs.
In the interim, alexAubin provides a JavaScript hack for form-template-validation.js to hide checkbox answers, display non-textarea questions on the same line, and fix spacing issues. satonotdead acknowledges the hack but notes that the current default styling, with its hardened subheadings, violates their community’s posting guidelines.
We’d love some control over this. In the meantime, I’m looking at making forms with spaces for labels (that way the * still shows up for required fields).
In the meantime, I came up with this ugly hack to a) hide “checkbox” answers, and b) display non-textarea questions on the same line (<question?>: <answer>) and c) fix spacing between items
If you’re somewhat familiar with Javascript, you can adapt it to your needs:
(This is to be added in app.yml’s hooks section)
hooks:
after_code:
- exec:
# Typically here you have the plugin thingies
- replace:
filename: /var/www/discourse/app/assets/javascripts/discourse/app/lib/form-template-validation.js
from: 'return formattedOutput.join("\n\n");'
to: |
const formattedOutput2 = mergedData.map((item) => {
const key = Object.keys(item)[0];
const value = item[key];
const type = formTemplate.find(x => x.id == key).type;
if (type == 'checkbox') return;
if ((value) && (type != 'textarea')) return `**${labelMap[key]}**: ${value}`;
if (value) return`\n### ${labelMap[key]}\n${value}\n`;
});
return formattedOutput2.join("\n");