Give me some control of how the form template post is styled

We aren’t fans of how the post resulting from a form template is styled.

Here’s what I expected to see:

Label: answer
Label: answer
Label: answer

See the markdown
**Label:** answer
**Label:** answer
**Label:** answer

Here’s what we got:

label

answer

label

answer

label

answer

See the markdown
> ### label
> answer
> 
> 
> 
> ### label
> answer
> 
> 
> ### label
> answer

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).

That yields something like this

answer

answer

answer

See the markdown
###
answer


###
answer


### 
answer

There’s still too much whitespace, but it’s… less unappealing.

Suggestion: How about making this an attribute of the form input? E.G.

- type: input
  id: rule
  attributes:
    label: "Label"
    placeholder: "say something!"
    answer-styling: bold
  validations:
    required: true
7 Likes

Following up on alternate presentations…

After showing my team this form & the resulting post output this morning in standup, the responses were

We’re missing the formatting toolbar at the top… I’m realizing I don’t want a form that makes a post; I want a normal post with some required fields

and

I wish these fields could be in a little box at the top [of the resulting post] or on the side or something

So… we’re eager to see how this evolves. :smiley:

3 Likes

For this use case you could just edit the regular topic template of a category:

And this could probably be achieved using the Discourse Templates plugin?

In any case… so many template options :exploding_head: :smile:

3 Likes

Hi,

We’ve got ‘normal’ templates in place in the relevant categories. That doesn’t mean that people provide the data they ask for. :sadpanda:

Ehm… No. This was about the presentation of the data gathered from form inputs.

Thanks, tho. :smiley:

3 Likes

+1 to the feature request.

And on a similar note, to give users the standard formatting toolbar for short and/or long-form textbox answers.

3 Likes

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");

1 Like