tinymce() form()

A textarea with the TinyMCE 8 rich text editor; without JavaScript it stays a plain textarea.

form()->tinymce($name, $desc = '', $extra = [], $replace = [])

Options

OptionMeaning
tinymce['config' => [...]]: tinymce.init() options over yf_form2_tinymce::$CONFIG and its defaults (data only).
(textarea options)Every option of textarea().

Example

Code

return form(['body' => '<p>Hello <b>world</b></p>'])
    ->tinymce('body', 'Text', ['rows' => 6, 'tinymce' => ['config' => ['menubar' => false]]]);

Notes

  • The editor reads the textarea as HTML, so the value is escaped with htmlspecialchars() (a stored < stays <).
  • Clean the posted HTML on the server before you show it to others.

Bootstrap 3 and 5

The editor follows the Bootstrap 5 colour mode (dark skin under data-bs-theme="dark").

See also: form/textarea, demo:form/tinymce