I've created a custom field that loads content from a given URL. The content is rendered with the given input format. That works fine.
Currently, I just gabe a list of available text input using filter_formats and show this with a select widget. How can I replace this with the standard input format widget that is available underneath the node body textarea?
This is how it's done now:
/**
* Implements hook_field_widget_form().
*/
function remote_content_field_widget_form(&$form, &$form_state, $field, $instance, $langcode, $items, $delta, $element) {
$url = isset($items[$delta]['url']) ? $items[$delta]['url'] : '';
$tformatter = isset($items[$delta]['tformatter']) ? $items[$delta]['tformatter'] : 0;
$widget = $element;
$widget += array(
...
);
$widget['url'] = array(
...
);
$widget['tformatter'] = array(
'#type' => 'select',
'#title' => t('Text format'),
'#options' => _remote_content_create_format_options(),
'#default_value' => $tformatter,
'#description' => t('Choose the appropriate text format.'),
);
$element = $widget;
return $element;
}
function _remote_content_create_format_options() {
global $user;
$formats = filter_formats($user);
$options = array();
foreach($formats as $f) {
$options[$f->format] = $f->name;
}
return $options;
}