views:

160

answers:

3

This drupal form snippet will give me a textarea with user able to change filter to full html/wysiwyg mode.

My Questions: How can I default to to full html mode?

function MY_MODULE_admin() {
  $form = array();

 $form['format'] = filter_form($form->format);

  // MY_MODULE - ** Image 1 **
    $form['MY_MODULE_image_1'] = array(
    '#type' => 'textarea',
    '#title' => t('Image 1'),
    '#default_value' => variable_get('setup_image_1', 'image_1.jpg'),
    '#description' => "Current value =" .variable_get('setup_image_1', 'image_1.jpg'),
    '#required' => TRUE,
  );
A: 

Well there are two ways.

One, you can set that role's default format to Full HTML under Input Formats.

Two, you can say $form['format']['#default_value'] = 2 (I think Full HTML is 2). This will preselect Full HTML.

Kevin
+2  A: 

This did the trick.

 $form = array();

 $form['carousel_setup_image_1']['accepted_text_1'] = array(
    '#type' => 'textarea',
    '#title' => t('Image 1 - Carousel '),
    '#default_value' => variable_get('carousel_setup_image_1', 'carousel_image_1.jpg'),
    '#description' => "Current value =" .variable_get('carousel_setup_image_1', 'carousel_image_1.jpg'),
  ); 
  $form['carousel_setup_image_1']['format'] = filter_form(2, NULL, array('accepted_text_1_format'));    
ernie
A: 
however, I am not sure why $edit['carousel_setup_image_1']['accepted_text_1']) does not contain entered value.

function carousel_setup_block($op = 'list', $delta = 0, $edit = array())
{
       switch($op)
        {

            // case save (save configuration values)       
            case 'save':
            variable_set('carousel_setup_image_1',                
                    $edit['carousel_setup_image_1']['accepted_text_1']);
                break;           
        }   
    }
ernie