2

An Textfield within my Custom Content Pane works fine.

An Textarea incl. input-filter ('#type' => 'text_format',) will not be saved.

<?php
  function text_edit_form($form, &$form_state) {
      $conf = $form_state['conf'];

      $form['form_text'] = array(
        '#type' => 'text_format',
        '#title' => t('Text'),
        '#format' => 'filtered_html',
        '#size' => 50,
        '#resizeable' => TRUE,
        '#default_value' => !empty($conf['form_text']) ? $conf['form_text'] : '',
      );

      return $form;
    } 
  function text_edit_form_submit($form, &$form_state) {
    foreach (array('form_text') as $key) {
      $form_state['conf'][$key] = $form_state['values'][$key];
    }
  }
?>

At drupal.com somebody wrotes, that #default_value expect and string, but text_format is an array. So he postet the following solution.

But how can I build that within my hook_edit_form?

<?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'],
      );
 ?>

Who can help me with that?

2

Solved!

I just rebuild the save-stuff:

<?php
function text_edit_form_submit($form, &$form_state) {
  $form_state['conf']['form_text'] = $form_state['values']['form_text']['value'];
}
?>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.