disable resizable textarea
peach - June 12, 2006 - 22:14
I'm using the webform module and loving it, but I dont like the resizable textarea to be enabled on the frontend of my website.
There doesn't seem to be an option to enable/disable it globally or in the webform module so I tried implementing this:
<?php
function mymodule_form_alter($form_id, &$form) {
foreach (element_children($form) as $key) {
if ($form[$key]['#type'] == 'textarea') {
$form[$key]['#resizable'] = false;
}
mymodule_form_alter($form_id, $form[$key]);
}
}
?>this code is made to stop WYSIWYG textareas to be resizable. I simply went through the webform files looking for the
[php]
'#type' => "textarea",
[/php]
code and putting:
'#resizable' = false;
right below it, but it did not seem to have effect.
Does anyone know a fix for me?
Thanks in advance,
JR

textarea
Hi peach,
You could try overriding the theme_textarea function.
in your template.php file add:
function phptemplate_textarea($element) {
$class = array('form-textarea');
$cols = $element['#cols'] ? ' cols="'. $element['#cols'] .'"' : '';
_form_set_class($element, $class);
return theme('form_element', $element, '<textarea'. $cols .' rows="'. $element['#rows'] .'" name="'. $element['#name'] .'" id="'. $element['#id'] .'" '. drupal_attributes($element['#attributes']) .'>'. check_plain($element['#value']) .'</textarea>');
}
It just leaves out the code below which makes the element resizeable.
if ($element['#resizable'] !== false) {drupal_add_js('misc/textarea.js');
$class[] = 'resizable';
}
---------------------
www.csscreator.com
disable resizeable text areas for 4.7
hiya,
The textarea labels displayed as just "array" when I used your snippet. Assume it's for 4.6 or an earlier version.
this snippet worked for 4.7:
(A) put this into a template.php file (use a text editor to create one if there isn't one already in your theme folder)
(B) Upload it to your theme folder to override the reasizable text area thingy
<?phpfunction phptemplate_textarea($element) {
$class = array('form-textarea');
$cols = $element['#cols'] ? ' cols="'. $element['#cols'] .'"' : '';
_form_set_class($element, $class);
return theme('form_element', $element['#title'], '<textarea'. $cols .' rows="'. $element['#rows'] .'" name="'. $element['#name'] .'" id="' . $element['#id'] .'" '. drupal_attributes($element['#attributes']) .'>'. check_plain($element['#value']) .'</textarea>', $element['#description'], $element['#id'], $element['#required'], form_get_error($element));
}
?>
hope that helps someone else. By using this snippet, you are just disabling the default textarea resizer for that specific theme.
Dub
thanks mate, I just settled
thanks mate, I just settled with the resizeable area on my last site but I'll bookmark this thread for my next sites :D
I tried that snippet in
I tried that snippet in 4.7.2 but keep getting the following errors when I switch back to a different theme.
Cannot modify header information - headers already sent by (output started at /home/httpd/vhosts/goldenboyband.com/httpdocs/content/themes/goldenboy/template.php:10) in /home/httpd/vhosts/goldenboyband.com/httpdocs/content/includes/common.inc on line 266.
Also when I tried to add a menu. I get a blank page.
Nice job... another implementation
Hi Dub,
You did a nice job... but maybe the following implementation is better. It is simpler and will also handle future changes in the theme_textarea core function:
function phptemplate_textarea($element){
$element['#resizable'] = false ;
return theme_textarea($element) ;
}
FredCK
Thanks Fred! I'm using this
Thanks Fred! I'm using this on www.JogMyMemory.co.za now. Saves me a lot of CSS hassles!
disable resizable textarea
The above solution works great in D6. Thanks for the post.
function phptemplate_textarea($element)
{
$element['#resizable'] = false ;
return theme_textarea($element) ;
}
Not working
Used this in my templates.php
<?phpfunction phptemplate_textarea($element)
{
$element['#resizable'] = false ;
return theme_textarea($element) ;
} ?>
The resizing grip is still visible on my textareas and I still see class "resizeable" in HTML. I am using marinelli theme... I also tried
<?phpfunction phptemplate_textarea($element)
{
$element['#resizable'] = false ;
return marinelli_textarea($element) ;
} ?>
Didn't work.
All core textareas vanished.
Hi,
<?phpfunction phptemplate_textarea($element)
{
$element['#resizable'] = false ;
return theme_textarea($element) ;
}
?>
The above shown code of FredCK is working in D6 but unfortunately it takes all drupal core textareas away. Totally vanished. It should only point to the webform module. Couldn't find the right code.
OK in D5
the above snippet worked fine in D5 when I tried it just now
I was even able to add
$element['#overflow'] = 'visible';and get a scrollbar so responses aren't limited to the size of the textarea when resizing is off.
I'm not doing any textareas in the webforms I'm using, but the above code is working for me in both my contact form (which is pretty much the only core textarea I'm using), and in my CCK forms.
salud,
Bill
Disable by permission
By this function in template.php I turned off resizing for non admin users. At least in D6.
<?phpfunction phptemplate_textarea($element){
if (!user_access('administer nodes')) {
$element['#resizable'] = false ;
}
$output = theme_textarea($element);
return $output;
}
?>
If someone wants to remove
If someone wants to remove the resizable part of a specific textarea, you can also JQuery for that (D6):
in your .js file:
Drupal.behaviors.your_module = function(context) {
$("#ID-of-the-textarea").removeClass('resizable');
}
or directly in PHP:
<?php
drupal_add_js('$(document).ready(function(){ $("#ID-of-the-textarea").removeClass("resizable");});', 'inline');
?>
works for me, hope that will help someone..