# Category custom field value strage behaviour in category edit form

**URL:** <https://meta.discourse.org/t/category-custom-field-value-strage-behaviour-in-category-edit-form/55807>\
**Category:** Development\
**Created:** [2017 年1 月 15 日 16:43 UTC](https://meta.discourse.org/t/category-custom-field-value-strage-behaviour-in-category-edit-form/55807 "2017-01-15T16:43:46Z")\
**Posts on this page:** 1\
**Showing post:** 1

<div class="post-metadata">

作者： ![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)\
发布日期： [2017 年1 月 15 日 16:43 UTC](https://meta.discourse.org/t/category-custom-field-value-strage-behaviour-in-category-edit-form/55807/1 "2017-01-15T16:43:46Z")

</div>

I’m about to create a plugin adding a checkbox to Category settings. All is fine with the field until I uncheck the field. In database I can see that value of custom field is set to “false” but as I reopen category settings the checkbox is now checked although the value is still false. Is there something I’m missing?

Here’s the custom field…

**~/bump-topic/assets/javascripts/discourse/pre-initializers/extend-for-bumping.js.es6**

```plaintext
import Category from 'discourse/models/category';
import computed from 'ember-addons/ember-computed-decorators';

export default {
  name: 'extend-for-bumping',
  before: 'inject-discourse-objects',
  initialize() {

    Category.reopen({

      @computed('custom_fields.enable_bump_topic')
      enable_bump_topic: {
        get(value) {
          return value === "true";
        },
        set(value) {
          value = value ? "true" : "false";
          this.set("custom_fields.enable_bump_topic", value);
          return value;
        }
      }
    });
  }
};

```

And the interface part…

**~/bump-topic/assets/javascripts/discourse/templates/connectors/category-custom-settings/bump-topic.hbs**

```plaintext
{{#if this.siteSettings.bump_topic_enabled}}
<section class='field'>
  <div class="enable-bump-topic">
    <label class="checkbox-label">
      {{input type="checkbox" checked=category.custom_fields.enable_bump_topic}}
      {{i18n 'bump_topic.enable_bump_topic'}}
    </label>
  </div>
</section>
{{/if}}

```

---

_[View the full topic](https://meta.discourse.org/t/category-custom-field-value-strage-behaviour-in-category-edit-form/55807)._
