2010-06-09 2 views
3

이 drupal 양식 스 니펫은 사용자가 필터를 전체 html/wysiwyg 모드로 변경할 수있는 텍스트 영역을 제공합니다.Drupal filter_form 양식 입력

내 질문 : 기본 HTML 모드로 기본 설정하려면 어떻게해야합니까?

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, 
); 

답변

0

글쎄 두 가지가 있습니다.

하나, 입력 형식에서 해당 역할의 기본 형식을 전체 HTML로 설정할 수 있습니다.

2 개를 사용하면 $ form [ 'format'] [ '# default_value'] = 2 (전체 HTML은 2라고 생각할 수 있습니다. 그러면 전체 HTML이 미리 선택됩니다.

3

트릭을 수행했습니다. 렌더링과 같이 처리하는 가장 좋은 방법 (또는 활용) 드루팔 텍스트 필터 시스템이 아닌 '텍스트 영역'을 사용하는 것입니다,하지만 'text_format'필드 유형, : 드루팔 7의

$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'));  
0
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;   
     } 
    } 
0

아래 필터 선택 텍스트 상자 :

 $form['holycrap'] = array(
     '#type' => 'text_format', 
     '#format' => NULL, // <- Let Drupal handle the default, based upon user role 
     '#title' => t('The HTML for the Holy Crap block above the Main Menu.'), 
     '#default_value' => variable_get('caplogin_holycrap', _caplogin_holycrap_default_html()), 
    ); 
    return $form;