"Illegal choice full_html in Text format element" when submitting form programatically 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' =&gt; 'footer_contact',
    'title' =&gt; 'TITLE',
    'info' =&gt; 'INFO',
    'body' =&gt; array(
      'value' =&gt; 'BODY TEXT',
      'format' =&gt; 'full_html',
    ),
    'regions' =&gt; array(
      'mytheme' =&gt; 'footer',
      'myadmintheme' =&gt; '-1',
    ),
    'visibility' =&gt; '0',
    'pages' =&gt; NULL,
    'custom' =&gt; '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?
You can try this.It works i think so

$form['formItem'] = array(
     '#type'=&gt;'text_format',
     '#title' =&gt; t('Field Label'),
     '#value' =&gt; 'This is my value',
     '#format'=&gt;'full_html',
);