hook_textarea

Versions
4.6
hook_textarea($op, $name)

React to textarea additions.

This hook allows a module to take action when a text area is placed on the page. In practice, it is used to build a catalog of text areas for later conversion into WYSIWYG editors.

As shown in this example, the HTMLArea module uses this hook to build JavaScript routines that convert text areas into HTMLArea editors if the browser has the capability to do so. (It returns no output.)

Parameters

$op When the hook is being called. Possible values:

  • "pre" - prior to drawing textarea
  • "post" - after drawing textarea

$name The "name" attribute of the text area being added.

Return value

HTML to be added before or after textarea (depending on $op).

Related topics

Code

developer/hooks/core.php, line 946

<?php
function hook_textarea($op, $name) {
  global $htmlarea_init, $htmlarea_fields, $htmlarea_codeview;

  if ($op == 'pre') {
    $real_name = $name;
    $name = _htmlarea_parse_name($name);

    if (_htmlarea_is_changed($name)) {
      $htmlarea_init[] = "var $name = null;";
      $htmlarea_fields[] = "attacheditor($name, '$name');";
    }
  }
}
?>
Login or register to post comments
 
 

All source code and documentation on this site is released under the terms of the GNU General Public License, version 2 and later. Drupal is a registered trademark of Dries Buytaert.