2010-04-21 12 views
5

Ist es möglich, einen WYSIWYG-Editor in Texarea für Drupal Site-Konfigurationsformular (System_Einstellungen_formular) zu verwenden. DieseWYSIWYG-Editor in Texarea für Drupal-Konfigurationsformular

ist, wie die Konfiguration nun codiert ...

$form['my_module_text_bottom'] = array(
    '#type' => 'textarea', 
    '#title' => t('Some text'), 
    '#default_value' => variable_get('my_module_text_bottom', 'This is configurable text found in the module configuration.'), 
    '#size' => 1024, 
    '#maxlength' => 1024, 
    '#description' => t("Some text."), 
    '#required' => TRUE, 
); 
    return system_settings_form($form); 

Antwort

0

Die WYSIWYG oder CKEditor Module sollten dies tun können.

+0

ja, sein sollte. Ich frage mich nur, wie ich das umsetzen soll. – bert

+0

Ich persönlich mag CKEditor; Sie würden dieses Modul herunterladen und installieren und dann die CKEditor-Bibliothek von der offiziellen Website herunterladen und in den richtigen Ordner stellen. Die Anweisungen führen Sie durch diese. – Nicholai

1

Ich hielt für etwa 6 Stunden für dieses Problem gesucht und ich fand schließlich den Grund für die benutzerdefinierte Textfeld Feld, das Sie diese Zeile hinzufügen muß, das Standard-Eingabeformat (Full HTML) zu verwenden:

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

vorsichtig sein, wenn Sie dieses Formular Element verwenden innerhalb Fieldset Sie dieses Fieldset muss Folgendes enthalten:

$ form [ 'Spenden Anweisungen'] [ 'format'] = filter_form();

Ich hoffe, dies wird Ihnen helfen

0

fand ich diese Frage ähnlich wie:

Drupal 6: Implement Wysiwyg on Custom Module Form

Eine der Antworten gibt auf diese drupal.org Seite zeigte:

http://drupal.org/node/358316

, die recht detaillierte Beispiele für die "Format" Array-Schlüssel und filter_form(), auch desc Rippen, wie es verwendet wird, wenn Ihre Form mehrere Textareas hat.

Der gegebene Ansatz dort nicht zu Drupal 7.

ich in eine ähnliche Situation gilt lief, wo ich würde heruntergeladen und installiert und installiert CKEditor und es angezeigt wird, wenn Inhalte Knoten bearbeiten, aber nicht für die Anzeige haben das Textfeld auf einem Konfigurationsformular für mein Modul.

4

Hier ist es for Drupal 7 und Drupal 6.

Für D7:

<?php 
    // Retrieve the default values for 'value' and 'format', if not readily 
    // available through other means: 
    $defaults = array(
    'value' => '', 
    'format' => filter_default_format(), 
); 
    $my_richtext_field = variable_get('my_richtext_field', $defaults); 

    // Just construct a regular #type 'text_format' form element: 
    $form['my_richtext_field'] = array(
    '#type' => 'text_format', 
    '#title' => t('My richtext field'), 
    '#default_value' => $my_richtext_field['value'], 
    '#format' => $my_richtext_field['format'], 
); 
?> 

Für D6:

<?php 
    // Your saved or new data is supposed to have a value and a format. Just like 
    // $node has a $node->body and $node->format. May also come from a 
    // variable_get('mymodule_admin_setting', array('value' => '', 'format' => NULL)); 
    $mydata = mymodule_data_load(); 

    $form['myfield']['mytextarea'] = array(
    '#type' => 'textarea', 
    '#title' => t('My textarea'), 
    '#default_value' => $mydata->value, 
); 
    $form['myfield']['format'] = filter_form($mydata->format); 
?> 
+1

Das ist wirklich eine bessere Antwort, da das WYSIWYG-Modul nichts ohne diesen Code machen wird. –

Verwandte Themen