<?php
function hook_field_settings_form($field, $instance, $has_data) {
$settings = $field['settings'];
$form['max_length'] = array(
'#type' => 'number',
'#title' => t('Maximum length'),
'#default_value' => $settings['max_length'],
'#required' => FALSE,
'#min' => 1,
'#description' => t('The maximum length of the field in characters. Leave blank for an unlimited size.'),
);
return $form;
}
function hook_field_instance_settings_form($field, $instance, $form_state) {
$settings = $instance['settings'];
$form['text_processing'] = array(
'#type' => 'radios',
'#title' => t('Text processing'),
'#default_value' => $settings['text_processing'],
'#options' => array(
t('Plain text'),
t('Filtered text (user selects text format)'),
),
);
if ($field['type'] == 'text_with_summary') {
$form['display_summary'] = array(
'#type' => 'select',
'#title' => t('Display summary'),
'#options' => array(
t('No'),
t('Yes'),
),
'#description' => t('Display the summary to allow the user to input a summary value. Hide the summary to automatically fill it with a trimmed portion from the main post.'),
'#default_value' => !empty($settings['display_summary']) ? $settings['display_summary'] : 0,
);
}
return $form;
}
function hook_field_formatter_settings_form_alter(&$element, &$form_state, $context) {
if ($context['field']['type'] == 'foo_field') {
$element['mysetting'] = array(
'#type' => 'checkbox',
'#title' => t('My setting'),
'#default_value' => $context['formatter']
->getSetting('mysetting'),
);
}
}
function hook_field_formatter_settings_summary_alter(&$summary, $context) {
if ($context['field']['type'] == 'foo_field') {
if ($context['formatter']
->getSetting('mysetting')) {
$summary[] = t('My setting enabled.');
}
}
}