# 让我对表单模板帖子的样式进行一些控制

**URL:** <https://meta.discourse.org/t/give-me-some-control-of-how-the-form-template-post-is-styled/296231>\
**Category:** Feature\
**Tags:** form-templates\
**Created:** [2024年二月21日 20:10 UTC](https://meta.discourse.org/t/give-me-some-control-of-how-the-form-template-post-is-styled/296231 "2024-02-21T20:10:06Z")\
**Posts on this page:** 1\
**Showing post:** 6

<div class="post-metadata">

**Author:** ![alexAubin](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/alexaubin/32/445866_2.png) [@alexAubin](https://meta.discourse.org/u/alexAubin)\
**Post date:** [2024年九月2日 23:35 UTC](https://meta.discourse.org/t/give-me-some-control-of-how-the-form-template-post-is-styled/296231/6 "2024-09-02T23:35:24Z")

</div>

与此同时，我想到了一种丑陋的解决方法来 a) 隐藏“复选框”答案，b) 在同一行显示非文本区域问题（`<question?>: <answer>`），以及 c) 修复项目之间的间距。

如果您对 Javascript 有一定的了解，可以根据自己的需要进行调整：

（这将被添加到 `app.yml` 的 hooks 部分）

```yml
hooks:
  after_code:
    - exec:
        # 通常在这里你会找到插件的东西
    - 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");

```

---

_[View the full topic](https://meta.discourse.org/t/give-me-some-control-of-how-the-form-template-post-is-styled/296231)._
