/[drupal]/contributions/modules/cck/includes/cck.text.inc
ViewVC logotype

Contents of /contributions/modules/cck/includes/cck.text.inc

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph


Revision 1.7 - (show annotations) (download) (as text)
Wed Apr 15 01:10:33 2009 UTC (7 months, 1 week ago) by yched
Branch: MAIN
Changes since 1.6: +3 -1 lines
File MIME type: text/x-php
Port of #399778 by Benjamin Melençon - Nodereference / Userreference: Add 'size' setting to autocomplete widgets.
+ fixes hook_field_widget_settings_form() implementations in user_ref and node_ref.
1 <?php
2 // $Id: cck.text.inc,v 1.6 2009/03/21 21:57:42 karens Exp $
3
4 /**
5 * Implementation of hook_field_settings_form()
6 * on behalf of core Text module.
7 */
8 function text_field_settings_form($field) {
9 $form = array();
10 $defaults = field_info_field_settings($field['type']);
11 $settings = array_merge($defaults, $field['settings']);
12 if (isset($defaults['max_length'])) {
13 $form['max_length'] = array(
14 '#type' => 'textfield',
15 '#title' => t('Maximum length'),
16 '#default_value' => !empty($settings['max_length']) && is_numeric($settings['max_length']) ? $settings['max_length'] : $defaults['max_length'],
17 '#required' => FALSE,
18 '#element_validate' => array('_element_validate_integer_positive'),
19 '#description' => t('The maximum length of the field in characters. Leave blank for an unlimited size.'),
20 );
21 }
22 return $form;
23 }
24
25 /**
26 * Implementation of hook_widget_settings_form()
27 * on behalf of core Text module.
28 */
29 function text_widget_settings_form($instance) {
30 $form = array();
31 $widget = $instance['widget'];
32 $defaults = field_info_widget_settings($widget['type']);
33 $settings = array_merge($defaults, $widget['settings']);
34 if ($widget['type'] == 'text_textfield') {
35 $form['size'] = array(
36 '#type' => 'textfield',
37 '#title' => t('Size of textfield'),
38 '#default_value' => $settings['size'],
39 '#element_validate' => array('_element_validate_integer_positive'),
40 '#required' => TRUE,
41 );
42 }
43 else {
44 $form['rows'] = array(
45 '#type' => 'textfield',
46 '#title' => t('Rows'),
47 '#default_value' => $settings['rows'],
48 '#element_validate' => array('_element_validate_integer_positive'),
49 '#required' => TRUE,
50 );
51 }
52 return $form;
53 }
54
55 /**
56 * Implementation of hook_field_instance_settings_form()
57 * on behalf of core Text module.
58 */
59 function text_field_instance_settings_form($field, $instance) {
60 $widget = $instance['widget'];
61 $field_type = field_info_field_types($field['type']);
62 $defaults = field_info_instance_settings($field['type']);
63 $settings = array_merge($defaults, $instance['settings']);
64 $options = array(0 => t('Plain text'), 1 => t('Filtered text (user selects input format)'));
65 $form['text_processing'] = array(
66 '#type' => 'radios',
67 '#title' => t('Text processing'),
68 '#default_value' => !empty($settings['text_processing']) && is_numeric($settings['text_processing']) ? $settings['text_processing'] : $defaults['text_processing'],
69 '#options' => $options,
70 );
71 if ($field['type'] == 'text_with_summary') {
72 $form['display_summary'] = array(
73 '#type' => 'select',
74 '#options' => array(0 => t('No'), 1 => t('Yes')),
75 '#title' => t('Display summary'),
76 '#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. '),
77 '#default_value' => !empty($settings['display_summary']) ? $settings['display_summary'] : 0,
78 );
79 }
80 return $form;
81 }

  ViewVC Help
Powered by ViewVC 1.1.2