How to get the standard text format widget for a custom field type?
You are looking for '#type' =&gt; 'text_format'. Usage example:

$form['text'] = array(
  '#type' =&gt; 'text_format',
  '#title' =&gt; t('Text'),
  '#default_value' =&gt; $text,
  '#format' =&gt; $format,
);


You will get the text in $form_state['values']['text']['value'] and the format in $form_state['values']['text']['format'].