I created new field field_csob_srcode in my custom code:
<?php
$field = array(
'field_name' => 'field_csob_srcode',
'type' => 'text',
'settings' => array(
'max_length' => 4,
),
);
field_create_field($field);
?>
I would need to create custom formatter for this field. I am using such implementation of hook_field_formatter_info
<?php
function mymodule_field_formatter_info() {
$info = array(
'csob_webpay_description' => array(
'label' => t('SRCODE - text description'),
'field types' => array('text'),
'description' => t('Displays text description of message from CSOB GP WebPay'),
),
);
return $info;
}
It works ok, but now, I see my new formatter as option at all fields settings, which have type = 'text'. Is it possible to restrict using of formatter, not only by field type, but also by field? When I try to set field in hook_field_formatter_info:
'field types' => array('field_csob_srcode'),
then it does not work, formatter disappears from options in field display settings.
EDIT: I have not problem to set formatter for my field, I just need to restrict formatter ONLY for my field. So other text fields cannot use my formatter. So the formatter will not appear as option in selectbox, when selecting format for display