Customizing create topic form to add more custom fields, what does add_to_serializer or register_custom_field_type do?

Hi I was looking into customizing create topic form.

  1. Removing the category option all together
  2. Adding custom field to the form.

Now I was able to add custom field using the plugin outlet composer-fields-below,
but how to integrate it with topic ? When the user clicks on “+ Create Topic” button, how to save the custom field along with the form?

Then I came to know about
User.register_custom_field_type(‘see_signatures’, :boolean)
in https://github.com/xfalcox/discourse-signatures/blob/master/plugin.rb#L15.

I tried doing
Topic.register_custom_field_type(‘custom_field’, :string)
But no result.

I just dont know how to pass the custom field value to the backend .
I tried browsing many discourse plugin in github, but could not understand.
what does add_to_serializer or register_custom_field_type do? Can you point me to its documentation?

4 « J'aime »

This is going to have bad effects on mobile, though if you are removing category and replacing it with another field, there should be room in the UI at least.

1 « J'aime »

I can change the height of create post box to include more custom fields.

But I am not able to figure out how to pass the value from custom field to TopicCustomField.
I tried browsing many plugins of discourse in github. Discourse-tagging ( depreciated) is the closest one that matches. I have posted snippet of that code in the question, … How do we pass the value from handlebar template to discourse topic?