Current status: Solved. . Done
Validation Failing on Required WYSIWYG Field
  • Ran into this bug on a project I'm working on:

    Create a custom fields definition that includes a WYSIWYG field that is marked as required.

    Create a new post and enter content into the wysiwyg field.

    Click "preview" (instead of saving a draft first)

    Even though there is content in the WYSIWYG field, the validation will fail.

    After tracking down the flow, it appears that do_validation is just checking the textarea.val(), which is empty because tinyMCE hasn't written content to it yet.

    Solution:
    At the top of do_validation, I've added the following code to check if a tinyMCE editor is on the screen, and if so, write content to its associated textarea:
    if ( (typeof tinyMCE != "undefined") && tinyMCE.activeEditor && !tinyMCE.activeEditor.isHidden() ) {
    tinyMCE.triggerSave();
    }


  • Hi @Conor,

    Great debugging! Yes, I'll add this to the todo and improve the do_validation to actually get the contents of the wysiwyg, not the textarea.

    Cheers
    Elliot
  • Hi @Conor,

    This has been fixed in the latest nightly build available here:
    https://github.com/elliotcondon/acf/

    Cheers
    Elliot