function text_noderef_field_widget_settings_form in Text or Nodereference 7
Implements hook_field_widget_settings_form().
File
- ./
text_noderef.module, line 169 - Text or nodereference field formatter for a text field and autocomplete widget.
Code
function text_noderef_field_widget_settings_form($field, $instance) {
$form = array();
$widget = $instance['widget'];
$settings = $widget['settings'];
if ($widget['type'] == 'text_noderef_textfield') {
// Reusing text_textfield widget type from text.module, then adding the
// autocomplete-related stuff.
$instance['widget']['type'] = 'text_textfield';
$form = text_field_widget_settings_form($field, $instance);
$bundles = array();
foreach (node_type_get_types() as $bundle) {
$bundles[$bundle->type] = $bundle->name;
}
$form['bundles'] = array(
'#type' => 'checkboxes',
'#title' => t('Content types for autocompleting on titles'),
'#options' => $bundles,
'#default_value' => $settings['bundles'],
'#description' => t('Autocompleting is done on all the content types if none of them is selected.'),
);
$form['autocomplete_match'] = array(
'#type' => 'select',
'#title' => t('Autocomplete matching'),
'#default_value' => $settings['autocomplete_match'],
'#options' => array(
'starts_with' => t('Starts with'),
'contains' => t('Contains'),
),
'#description' => t('Select the method used to collect autocomplete suggestions. Note that <em>Contains</em> can cause performance issues on sites with thousands of records.'),
);
$form['case_sensitive'] = array(
'#type' => 'radios',
'#title' => t('Case sensitive'),
'#default_value' => $settings['case_sensitive'],
'#options' => array(
0 => t('Disabled'),
1 => t('Enabled'),
),
);
$form['case_sensitive']['#description'] = theme('item_list', array(
'items' => array(
t('Case-insensitive queries are implemented using the <a href="!function-lower-url">LOWER()</a> function in combination with the <a href="!operator-like-url">LIKE</a> operator.', array(
'!function-lower-url' => 'http://dev.mysql.com/doc/refman/5.1/en/string-functions.html#function_lower',
'!operator-like-url' => 'http://dev.mysql.com/doc/refman/5.1/en/string-comparison-functions.html#operator_like',
)),
t('Note that MySQL might ignore case sensitivity depending on the collation used in your database definition (see <a href="!mysql-i18n-l10n-url">Internationalization and Localization</a> chapter in the MySQL manual). If you need case insensitive checks, it is recommended (for performance reasons) to use a case insensitive collation as well (such as utf8_general_ci), rather than disabling the case sensitive option here.', array(
'!mysql-i18n-l10n-url' => 'http://dev.mysql.com/doc/refman/5.1/en/internationalization-localization.html',
)),
t('You may want to create an expression index using the LOWER() function to speed up this kind of queries in PostgreSQL (See <a href="!indexes-expressional-url">Indexes on Expressions</a>).', array(
'!indexes-expressional-url' => 'http://www.postgresql.org/docs/8.4/static/indexes-expressional.html',
)),
),
));
}
return $form;
}