Fix for Removing an element #process function, yuk!

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