Helper function for color_field_field_instance_settings_form().
1 call to _color_field_field_instance_settings_form()
- color_field_field_instance_settings_form in ./
color_field.field.inc - Implements hook_field_instance_settings_form().
File
-
./
color_field_admin.inc, line 28
Code
function _color_field_field_instance_settings_form($field, $instance) {
$widget = $instance['widget'];
$instance_settings = $instance['settings'];
$form = array();
switch ($widget['type']) {
// Spectrum widget.
case 'color_field_spectrum_widget':
$form['show_input'] = array(
'#type' => 'checkbox',
'#title' => t('Show Input'),
'#default_value' => $instance_settings['show_input'],
'#description' => t('Allow free form typing.'),
);
$form['show_palette'] = array(
'#type' => 'checkbox',
'#title' => t('Show Palette'),
'#default_value' => $instance_settings['show_palette'],
'#description' => t('Show or hide the palette.'),
);
$form['palette'] = array(
'#type' => 'textarea',
'#title' => t('Color Palette'),
'#default_value' => $instance_settings['palette'],
'#description' => t('Selectable color palette to accompany the Spectrum widget.'),
'#states' => array(
'visible' => array(
':input[name="instance[settings][show_palette]"]' => array(
'checked' => TRUE,
),
),
),
);
$form['show_palette_only'] = array(
'#type' => 'checkbox',
'#title' => t('Show Palette Only'),
'#default_value' => $instance_settings['show_palette_only'],
'#description' => t('Only show the palette in Spectrum widget and nothing else.'),
);
$form['show_buttons'] = array(
'#type' => 'checkbox',
'#title' => t('Show Buttons'),
'#default_value' => $instance_settings['show_buttons'],
'#description' => t('Add Cancel/Confirm buttons.'),
);
$form['allow_empty'] = array(
'#type' => 'checkbox',
'#title' => t('Allow Empty'),
'#default_value' => $instance_settings['allow_empty'],
'#description' => t('Allow empty value.'),
);
break;
// Spectrum default widget.
case 'color_field_default_widget':
$form['default_colors'] = array(
'#type' => 'textarea',
'#title' => t('Default colors'),
'#default_value' => $instance_settings['default_colors'],
'#required' => TRUE,
'#description' => t('Default colors for pre-selected color boxes'),
);
break;
// Spectrum simple widget.
// Use to be color_field_simple_color.
case 'color_field_simple_color':
case 'color_field_simple_widget':
$form['cell_width'] = array(
'#type' => 'textfield',
'#title' => t('Cell width'),
'#description' => t('Width of each individual color cell.'),
'#default_value' => $instance_settings['cell_width'],
'#required' => TRUE,
);
$form['cell_height'] = array(
'#type' => 'textfield',
'#title' => t('Height width'),
'#description' => t('Height of each individual color cell.'),
'#default_value' => $instance_settings['cell_height'],
'#required' => TRUE,
);
$form['cell_margin'] = array(
'#type' => 'textfield',
'#title' => t('Cell margin'),
'#description' => t('Margin of each individual color cell.'),
'#default_value' => $instance_settings['cell_margin'],
'#required' => TRUE,
);
$form['box_width'] = array(
'#type' => 'textfield',
'#title' => t('Box width'),
'#description' => t('Width of the color display box.'),
'#default_value' => $instance_settings['box_width'],
'#required' => TRUE,
);
$form['box_height'] = array(
'#type' => 'textfield',
'#title' => t('Box height'),
'#description' => t('Height of the color display box.'),
'#default_value' => $instance_settings['box_height'],
'#required' => TRUE,
);
$form['columns'] = array(
'#type' => 'textfield',
'#title' => t('Columns number'),
'#description' => t('Number of columns to display. Color order may look strange if this is altered.'),
'#default_value' => $instance_settings['columns'],
'#required' => TRUE,
);
break;
}
return $form;
}