Please upgrade here. These earlier versions are no longer being updated and have security issues.
HackerOne users: Testing against this community violates our program's Terms of Service and will result in your bounty being denied.
Options

Disable the Body is required message.

2»

Comments

  • Options
    hgtonighthgtonight ∞ · New Moderator

    Well, I did say should. ;)

    I can't see why they would define 'Body' as required since it is already in the schema. This code definitely smells.

    No matter, you should be able to modify the validation object before saving the discussion. I actually tested this:

    public function discussionModel_beforeSaveDiscussion_handler($sender) {
        $sender->Validation->UnapplyRule('Body', 'Required');
    }
    
    public function Structure() {
        $Structure = Gdn::Structure();
        $Structure->Table('Discussion')
                ->Column('Body', 'text', TRUE, 'fulltext')
                ->Set();
        $Structure->Table('Comment')
                ->Column('Body', 'text', TRUE, 'fulltext')
                ->Set();
    }
    
    public function Setup() {
        $this->Structure();
    }
    

    Search first

    Check out the Documentation! We are always looking for new content and pull requests.

    Click on insightful, awesome, and funny reactions to thank community volunteers for their valuable posts.

  • Options

    @hgtonight and @R_J,

    Thanks! It works! (I tried @hgtonight's last code)

Sign In or Register to comment.