function viewfield_field_instance_settings_form in Viewfield 7.3
Same name and namespace in other branches
- 7.2 viewfield.module \viewfield_field_instance_settings_form()
Implements hook_field_instance_settings_form().
See also
viewfield_field_instance_settings_form_validate()
File
- ./
viewfield.module, line 46 - Defines a field type to display a view.
Code
function viewfield_field_instance_settings_form($field, $instance) {
$form['#field_name'] = $field['field_name'];
$form['force_default'] = array(
'#type' => 'checkbox',
'#title' => t('Always use default value'),
'#default_value' => $instance['settings']['force_default'],
'#description' => t('Hides this field in forms and enforces the configured default value.'),
);
$form['view_label'] = array(
'#type' => 'select',
'#title' => t('View label'),
'#options' => array(
'human' => t('Human name'),
'machine' => t('Machine name'),
'human_machine' => t('Human and machine name'),
'hidden' => t('Hidden'),
),
'#default_value' => isset($instance['settings']['view_label']) ? $instance['settings']['view_label'] : 'human',
'#description' => t('Select how the view name will be displayed to content authors. "Human" is the human readable name of a view ("My View"), while "machine" is a coded name ("my_view").'),
);
$form['display_label'] = array(
'#type' => 'select',
'#title' => t('Display label'),
'#options' => array(
'human' => t('Human name'),
'machine' => t('Machine name'),
'human_machine' => t('Human and machine name'),
),
'#default_value' => isset($instance['settings']['display_label']) ? $instance['settings']['display_label'] : 'human',
'#description' => t('Select how the view display name will be shown to content authors. "Human" is the human readable name of a display ("My View Display"), while "machine" is a coded name ("my_view_display").'),
);
$options = array();
$views = views_get_enabled_views();
ksort($views);
foreach ($views as $view) {
foreach ($view->display as $display) {
$options[$view->name . '|' . $display->id] = $view->human_name . ' (' . $view->name . ') - ' . $display->display_title . ' (' . $display->id . ')';
}
}
$form['allowed_views'] = array(
'#type' => 'checkboxes',
'#title' => t('Allowed values'),
'#options' => $options,
'#default_value' => isset($instance['settings']['allowed_views']) && is_array($instance['settings']['allowed_views']) ? $instance['settings']['allowed_views'] : array(),
'#description' => t('Only selected views will be available for content authors. Leave empty to allow all.'),
);
$form['#element_validate'] = array(
'viewfield_field_instance_settings_form_validate',
);
return $form;
}