I have a customized module that requires tinyMCE as a library.

enter image description here

After module installation, I still have to set my text editor in the image above. It was found in the admin/config/content/wysiwyg.

How will I programatically set tinyMCE as a default text editor right after module installation?

1 Answer 1


Below code is used in wysiwyg_profile_form_submit() at wysiwyg.admin.inc. You can make use of it.

// Insert new profile data.
  ->key(array('format' => $format))
    'editor' => $editor,
    'settings' => serialize($values),

Another approach is using drupal_form_submit() to submit its settings form programmatically. But it would be more compliated.

Also, before settings the profile, you need to check if tinymce is existing.

if (wysiwyg_get_editor('tinymce')) {

  // set profile.

  • Where will I get the value for $values?
    – user46175
    Commented Aug 4, 2016 at 1:53
  • 1
    The $values is from $form_state['values'] (source). It is quite hard to build the array by yourself. You can save the settings first, then copy the value on settings column in table wysiwyg, then use unserialize tool to convert the string into array.
    – Jimmy Ko
    Commented Aug 4, 2016 at 2:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.