Accept BB code in a generic text input and render as HTML

Chris D

XenForo developer
Staff member
I want to put a generic text input box in a template which, on submission, then puts that input into the database.

I can do that, no problem.

What I want is for the text box to be able to accept BB code and when the contents of this text box is rendered somewhere, it should render it as HTML.

I vaguely remember seeing somewhere how XenForo handles this for posts, but I can't remember for the life of me where.

Jake Bunce

XenForo moderator
Staff member
That is done in the view. See this class for a code example:


There is a helper and everything.

Chris D

XenForo developer
Staff member
Thank you Jake,

I'm struggling a little bit on this one :(

I might have implemented it wrong, but I'm getting:

An exception occurred: Undefined index: message in C:\wamp\www\library\XenForo\ViewPublic\Helper\Message.php on line 19
Which kinda makes sense because it's not a message I'm trying to view.

Although not exactly what I'm trying to achieve, I guess the way I'm thinking about it is if you consider Kier's old scratchpad add-on:

What I want to do is whatever you'd need to do for that text input box to accept and then render BB Code.