Disable re-sizable functionality on a textarea

Last modified: August 26, 2009 - 22:10

To remove the re-sizable functionality of a text area use the theme_textarea() function. We will override it in our template.php:

To disable the re-sizable on all text areas use this function in the template.php file located in your theme directory.

<?php
/**
Removes re-sizable functionality on all text areas
**/
function phptemplate_textarea($element){
 
$element['#resizable'] = false ;
  return
theme_textarea($element);
}
?>

The following function will remove the re-sizable functionality for one specific form, in which case we would do as follows:

<?php
/**
Removes re-sizable functionality on a single text areas
**/
function phptemplate_textarea($element){
 
// if the title of our element is the one we want, then disable re-sizable
 
if ($element['#title'] == 'Message'){
     
$element['#resizable'] = false ;
    }

 
$output = theme_textarea($element);
 
// Uncomment the line below to see what the title of the form element you want to override is
  //$output .= print_r($element);
 
return $output;
}
?>

To find out the element name use print_r($element). The title of the element can be found using print_r($element). A cleaner easier to read approach is to utilizing the devel module.

In this example we use 'Message' as the title of the element. The resulting code is:
textarea [#title] => Message

Look for something similar when you use print_r($element)

 
 

Drupal is a registered trademark of Dries Buytaert.