Search code examples
phpdrupaldrupal-6wysiwyg

Enable WYSIWYG for a custom textarea form field in drupal


i have created a custom form in my custom drupal6 module and the form has a textarea. I am outputting the form as html embedded inside the php code, like the following:

function custom_my_form() 
{
$f = '<form name="add_user" action="" method="post">
<label>  Name </label>
<p><input type="text" name="name" value="" /></p>
<label>About Yourself</label>
<p><textarea name="desc"></textarea></p>
<input type="submit" name="submit" value="Add">
</form>';

return $f;
}

I have installed and enabled the WYSIWYG module. My default input format is "Filtered HTML" and i have chosen the FCK editor for this input format.

Now i want to enable the WYSIWYG for the textarea field in this form. How can i go ahead with this ?


Solution

  • First, you should not create forms like that. Instead, use Drupal's built-in Forms API. Take a look at the Form API Quickstart Guide for more information.

    This page on Drupal's site will help you add WYSIWYG to your custom forms: http://drupal.org/node/358316