luwes / craft-codemirror

Add the awesome in-browser code editor CodeMirror as a field type.
MIT License
18 stars 10 forks source link

Fix codemirror field for draft entries #14

Closed jeffturcotte closed 4 years ago

jeffturcotte commented 5 years ago

This fixes the issue where codemirror field data would not get saved on new/draft entries in Craft 3.2+. The issue stems from how Craft now handles draft forms. It generates an entirely new form and submits that, which breaks codemirror's internal submit handler. That handler is supposed to copy the data out to the original textarea, but it never fires.

The fix works around this by listening to codemirror's change event and copying data out as it is entered.

Thanks.

jeffturcotte commented 4 years ago

Any chance this can get reviewed and merged? Thanks!