# How to add custom field to topic?

**URL:** https://meta.discourse.org/t/how-to-add-custom-field-to-topic/57948
**Category:** Development
**Created:** [2017年二月25日 16:46 UTC](https://meta.discourse.org/t/how-to-add-custom-field-to-topic/57948 "2017-02-25T16:46:16Z")
**Posts on this page:** 1
**Showing post:** 2

<div class="post-metadata">

### Author: ![Janno\_Liivak](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/janno_liivak/32/352215_2.png) [@Janno\_Liivak](https://meta.discourse.org/u/Janno_Liivak)
#### Post date: [2017年三月5日 22:01 UTC](https://meta.discourse.org/t/how-to-add-custom-field-to-topic/57948/2 "2017-03-05T22:01:17Z")

</div>

I’m really stuck here ☹  
I just don’t get it … what do I have to add to plugin.rb in order my plugin to have access to custom fields? As I understood, topics should already have custom field functionality by default.

I have code in pre-initializer…

```
    Topic.reopen({

      @property('custom_fields.bumped_at_with_button')
      bumped_at_with_button: {
        get(date_value) {
          return new Date(date_value);
        },
        set(value) {
          this.set('custom_fields.bumped_at_by_button', (value ? value.toISOString() : ''));
          return value;
        }
      }

    });

```

I have following section in plugin.rb…

```
add_to_serializer(:topic_view, :bumped_at_with_button, false) {
  object.topic.custom_fields['bumped_at_with_button']
}

```

But when setting value with…

```
topic.set('custom_fields.bumped_at_with_button')

```

… I get the message I pointed out in topic ☹

Help… anybody?

---

_[View the full topic](https://meta.discourse.org/t/how-to-add-custom-field-to-topic/57948)._
