hook_textarea

Definition

hook_textarea($op, $name)
developer/hooks/core.php, line 946

Description

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

Namesort iconDescription
HooksAllow modules to interact with the Drupal core.

Code

<?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');";
    }
  }
}
?>
 
 

Drupal is a registered trademark of Dries Buytaert.