Im trying to create a block programatically. I have created a function, which does the work for me.
function _create_footer_contact() {
form_load_include($form_state, 'inc', 'block', 'block.admin');
$form_state = array();
$form_state['values'] = array(
'machine_name' => 'footer_contact',
'title' => 'TITLE',
'info' => 'INFO',
'body' => array(
'value' => 'BODY TEXT',
'format' => 'full_html',
),
'regions' => array(
'mytheme' => 'footer',
'myadmintheme' => '-1',
),
'visibility' => '0',
'pages' => NULL,
'custom' => '0'
);
drupal_form_submit('block_add_block_form', $form_state);
}
The problem is the 'format' value, which throws an error if it is set to anything but 'plain_text' (if format is set to 'plain_text' the form submits nicely and a block is created).
WD form: Illegal choice full_html in Text format element.
An illegal choice has been detected. Please contact the site administrator.
To debug I have tried to examine the $form_state of 'block_add_block_form' using hook_form_alter and dpm(). When I manually submit a block the 'format' is set to 'full_html'.
So... how do I submit a form programatically with full_html set as format?