Cannot trigger CKEditor WYSIWYG in form API I’m using Drupal 7.18 with CKEditor 4.3 (full package), and trying to get a WYSIWYG field via the form API. My code:

function article_edit_form($form, &amp;$form_state, $article)
{
    // ...

    return array(
        // ...
        'content'  =&gt; array(
            '#type'    =&gt; 'text_format',
            '#title'   =&gt; t('Content'),
            '#format'  =&gt; 'full_html',
            '#wysiwyg' =&gt; true,
            '#input_format' =&gt; '1',
            '#value'   =&gt; array(
                'value'  =&gt; is_null($article) ? '' : $article-&gt;content,
                'format' =&gt; 'full_html'
            )
        ),
        // ...
    );
}


But this only displays a regular textarea with a section to choose the “text format”. The CKEditor is installed, enabled and I’m logged as admin.
There are a couple of things that you could try changing:


#input_format and #wysiwyg are not in the list of available properties for a text_format element, so even if they're not causing the error, you should probably remove them.
You shouldn't set the #value of an element like that (unless it's a value type itself). Instead you should use #default_value. In the case of a text_format the #default_value is expecting the text for the text area (since you've already set the format with #format).


I would expect this to work (certainly does for me if memory serves), but if not, check the console for JS errors

return array(
    // ...
    'content'  =&gt; array(
        '#type'    =&gt; 'text_format',
        '#title'   =&gt; t('Content'),
        '#format'  =&gt; 'full_html',
        '#default_value' =&gt; is_null($article) ? '' : $article-&gt;content
    ),
    // ...
);