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


(Net Deamon) #1

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 discourse-signatures/plugin.rb at master · xfalcox/discourse-signatures · GitHub.

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?


(Jeff Atwood) #2

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.


How do you learn how to build these plugins
(Net Deamon) #3

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?