Removing an element #process function, yuk!

  1. /**
  2.  * Implementation of hook_form_alter().
  3.  */
  4. function wysiwyg_form_alter(&$form, &$form_state, $form_id) {
  5.   $form['#input'] = TRUE;
  6. }
  7.  
  8. function wysiwyg_process_form($form) {
  9.   $form['#input'] = FALSE;
  10.   wysiwyg_purge_form($form);
  11.   return $form;
  12. }
  13.  
  14. /**
  15.  * This is a cleanup function to remove the processing done by other editors
  16.  * on textareas. The WYSIWYG Framework instead manages including all editors
  17.  * when necessary on textareas.
  18.  */
  19. function wysiwyg_purge_form(&$form) {
  20.   foreach (element_children($form) as $key) {
  21.     wysiwyg_purge_form($form[$key]);
  22.     if (isset($form['#type']) && $form['#type'] == 'textarea') {
  23.       $editors = array_keys(wysiwyg_get_editors());
  24.       foreach ($form['#process'] as $key => $function) {
  25.         foreach ($editors as $editor) {
  26.           if (strpos($function, $editor) === 0) {
  27.             unset($form['#process'][$key]);
  28.           }
  29.         }
  30.       }
  31.     }
  32.   }
  33. }