Saving a field of type 'text_format' as a system setting variable I'm attempting to give my content editors the ability to change a variable for a custom module. This variable can have html. I don't want to require them to have any knowledge of HTML, so I want to give them the ability to have our wysiwyg (CKEditor provided by the CKEditor module) at their disposal. However, as of now, the data does not save as a variable. I've read in a few places (D.o, stackexchange) that I needed to do something like this:

  $form['foo']['bar'] = array(
    '#type'     =&gt; 'text_format',
    '#title'    =&gt; 'Bar',
    '#definition' =&gt; 'Foo Bar',
    '#default_value' =&gt; variable_get('bar', ''),
    '#weight'   =&gt; 1,
    '#format' =&gt; 'filtered_html',
    '#required' =&gt; FALSE,
  ); 


This does not work out-of-the-box with a system_settings_form($form). A var_dump shows this after a save:

array (size=7)
  '#type' =&gt; string 'text_format' (length=11)
  '#title' =&gt; string 'Bar' (length=7)
  '#definition' =&gt; string 'Foo Bar' (length=74)
  '#default_value' =&gt; 
    array (size=2)
      'value' =&gt; string '' (length=0)
      'format' =&gt; string 'filtered_html' (length=9)
  '#weight' =&gt; int 1
  '#format' =&gt; string 'filtered_html' (length=9)
  '#required' =&gt; boolean false


From this, you can see that 'format' saves correctly, but 'value' does not. What am I missing?

Also, if there is a better way to do this, please do tell.
The following worked for me; the #default_value is expecting a string but the text_format form element is stored as an array.

$barvalue = variable_get('bar', array('value' =&gt; '', 'format' =&gt; NULL));

$form['foo']['bar'] = array(
'#type'     =&gt; 'text_format',
'#title'    =&gt; 'Bar',
'#definition' =&gt; 'Foo Bar',
'#default_value' =&gt; $barvalue['value'],
'#weight'   =&gt; 1,
'#format' =&gt; $barvalue['format'],
'#required' =&gt; FALSE,
);