# \[已解决\] 如何在\<head\>中使用 virtual-dom 的"h"辅助函数来覆盖 header-dropdown 汉堡菜单小部件？+ 如何覆盖 @computed 方法？

**URL:** <https://meta.discourse.org/t/solved-how-to-use-virtual-doms-h-helper-in-head-for-header-dropdown-hamburger-widget-override-how-to-override-computed-method/104583>\
**Category:** Development\
**Created:** [2018 年12 月 18 日 18:50 UTC](https://meta.discourse.org/t/solved-how-to-use-virtual-doms-h-helper-in-head-for-header-dropdown-hamburger-widget-override-how-to-override-computed-method/104583 "2018-12-18T18:50:30Z")\
**Posts on this page:** 1\
**Showing post:** 8

<div class="post-metadata">

作者： ![rbrlortie](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/rbrlortie/32/166740_2.png) [@rbrlortie](https://meta.discourse.org/u/rbrlortie)\
发布日期： [2018 年12 月 18 日 21:13 UTC](https://meta.discourse.org/t/solved-how-to-use-virtual-doms-h-helper-in-head-for-header-dropdown-hamburger-widget-override-how-to-override-computed-method/104583/8 "2018-12-18T21:13:13Z")

</div>

Awesome, this worked really well!

* * *

Here is the snippet for the composer window’s categoryValidation override, if anyone stumble here using the search.

```plaintext
<script type="text/discourse-plugin" version="0.8.23">
const computed = require("ember-addons/ember-computed-decorators").default;
api.modifyClass('controller:composer', {
    @computed("model.categoryId", "lastValidatedAt")
    categoryValidation(categoryId, lastValidatedAt) {
        var InputValidation = require("discourse/models/input-validation").default;
        var categoryDepth = /*Find categoryId's category level*/;
        if(this.get('model').draftKey == "new_topic" && (categoryDepth !== 0 && categoryDepth < 2)) {
            return InputValidation.create({
                failed: true,
                reason: 'You need to select a subcategory',
                lastShownAt: lastValidatedAt
              }); //THIS WORKS AND DISPLAY AN CUSTOM ERROR MESSAGE
        } else {
            return this._super(categoryId, lastValidatedAt);
        }
    }
});
</script>

```

---

_[View the full topic](https://meta.discourse.org/t/solved-how-to-use-virtual-doms-h-helper-in-head-for-header-dropdown-hamburger-widget-override-how-to-override-computed-method/104583)._
