function hook_field_widget_settings_form

Add settings to a widget settings form.

Invoked from field_ui_field_edit_form() to allow the module defining the widget to add settings for a widget instance.

Parameters

$field: The field structure being configured.

$instance: The instance structure being configured.

Return value

The form definition for the widget settings.

Related topics

5 functions implement hook_field_widget_settings_form()

Note: this list is generated by pattern matching, so it may include some functions that are not actually implementations of this hook.

field_test_field_widget_settings_form in modules/field/tests/field_test.field.inc
Implements hook_field_widget_settings_form().
file_field_widget_settings_form in modules/file/file.field.inc
Implements hook_field_widget_settings_form().
image_field_widget_settings_form in modules/image/image.field.inc
Implements hook_field_widget_settings_form().
options_field_widget_settings_form in modules/field/modules/options/options.module
Implements hook_field_widget_settings_form().
text_field_widget_settings_form in modules/field/modules/text/text.module
Implements hook_field_widget_settings_form().
1 invocation of hook_field_widget_settings_form()
field_ui_field_edit_form in modules/field_ui/field_ui.admin.inc
Form constructor for the field instance settings form.

File

modules/field_ui/field_ui.api.php, line 107

Code

function hook_field_widget_settings_form($field, $instance) {
    $widget = $instance['widget'];
    $settings = $widget['settings'];
    if ($widget['type'] == 'text_textfield') {
        $form['size'] = array(
            '#type' => 'textfield',
            '#title' => t('Size of textfield'),
            '#default_value' => $settings['size'],
            '#element_validate' => array(
                'element_validate_integer_positive',
            ),
            '#required' => TRUE,
        );
    }
    else {
        $form['rows'] = array(
            '#type' => 'textfield',
            '#title' => t('Rows'),
            '#default_value' => $settings['rows'],
            '#element_validate' => array(
                'element_validate_integer_positive',
            ),
            '#required' => TRUE,
        );
    }
    return $form;
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.