function viewreference_field_settings_form in View reference 7.3
Implements hook_field_settings_form().
File
- ./
viewreference.module, line 122 - Defines a field type for referencing a view from a node.
Code
function viewreference_field_settings_form($field, $instance, $has_data) {
$settings = $field['settings'];
$form = array();
$form['referenceable_views'] = array(
'#type' => 'checkboxes',
'#title' => t('Views that can be referenced'),
'#description' => t('Select the Views that can be referenced. If no Views are selected here, and tags are not entered below, then all the Views will be available.'),
'#multiple' => TRUE,
'#default_value' => is_array($settings['referenceable_views']) ? $settings['referenceable_views'] : array(),
'#options' => viewreference_get_views($settings['append_id']),
);
$form['referenceable_tags'] = array(
'#type' => 'fieldset',
'#title' => t('Views tags that can be referenced'),
'#collapsible' => TRUE,
'#collapsed' => !empty($settings['referenceable_tags']['allow']) || !empty($settings['referenceable_tags']['deny']) ? FALSE : TRUE,
'#description' => t('Optionally you can allow views by tags here instead of, or in addition to, using <em>Views that can be referenced</em>, then other Views will be excluded. You can also deny views by tags, and if <em>Views that can be referenced</em> and the <em>Allow list</em> are left blank all other Views will be available.'),
);
$form['referenceable_tags']['allow'] = array(
'#type' => 'textfield',
'#title' => t('Allow list'),
'#default_value' => !empty($settings['referenceable_tags']['allow']) ? $settings['referenceable_tags']['allow'] : '',
'#size' => 128,
'#maxlength' => 512,
'#description' => t('Enter a comma delimited list of tags to include.'),
);
$form['referenceable_tags']['deny'] = array(
'#type' => 'textfield',
'#title' => t('Deny list'),
'#default_value' => !empty($settings['referenceable_tags']['deny']) ? $settings['referenceable_tags']['deny'] : '',
'#size' => 128,
'#maxlength' => 512,
'#description' => t('Enter a comma delimited list of tags to exclude.'),
);
$form['arguments'] = array(
'#type' => 'fieldset',
'#title' => t('Contextual filter arguments'),
'#collapsible' => TRUE,
'#collapsed' => $settings['arguments']['dsv_arguments'] || $settings['arguments']['php_arguments'] ? FALSE : TRUE,
'#description' => t('Enabling the following options will provide an input field for passing arguments (aka <em>contextual filters</em>) to the View.'),
);
$form['arguments']['dsv_arguments'] = array(
'#type' => 'checkbox',
'#title' => t('Allow delimiter seperated values.'),
'#default_value' => isset($settings['arguments']['dsv_arguments']) ? $settings['arguments']['dsv_arguments'] : 0,
'#description' => t('Users can provide a list of arguments seperated by a delimiter. e.g: <em>term_1/term_2</em>'),
);
$form['arguments']['php_arguments'] = array(
'#type' => 'checkbox',
'#title' => t('Allow PHP code.'),
'#default_value' => isset($settings['arguments']['php_arguments']) ? $settings['arguments']['php_arguments'] : 0,
'#description' => t('Users can insert PHP code to generate the list of arguments. e.g: <em>term_1/<?php print "term_x/term_y"; ?>/term_2</em>') . '<br />' . t('Note: The users must have the <em>use PHP for settings</em> permission.'),
'#disabled' => !user_access('use PHP for settings'),
);
$form['arguments']['delimiter'] = array(
'#type' => 'textfield',
'#title' => t('Delimiter'),
'#default_value' => !empty($settings['arguments']['delimiter']) ? $settings['arguments']['delimiter'] : '/',
'#size' => 3,
'#maxlength' => 30,
'#required' => TRUE,
);
$row_range = range(0, 10);
unset($row_range[0]);
$form['arguments']['rows'] = array(
'#type' => 'select',
'#title' => t('Number of rows in argument field'),
'#default_value' => isset($settings['arguments']['rows']) ? $settings['arguments']['rows'] : 1,
'#options' => $row_range,
'#description' => t('Set as 1 for textfield, or larger values for textarea (may be easier to write PHP with a textarea)'),
'#required' => TRUE,
);
$form['arguments']['label'] = array(
'#type' => 'textfield',
'#title' => t('Label for arguments field'),
'#default_value' => isset($settings['arguments']['label']) ? $settings['arguments']['label'] : '!field_label ' . t('arguments'),
'#description' => t('Use <em>!field_label</em> to insert the field label.'),
);
$form['append_id'] = array(
'#type' => 'checkbox',
'#title' => t('Append unique ID in lists.'),
'#default_value' => isset($settings['append_id']) ? $settings['append_id'] : 0,
'#description' => t('It is possible for Views displays to have the same title, this option will append [view:view_display_n] in lists used by this field to disambiguate the options.'),
);
$form['skip_default'] = array(
'#type' => 'checkbox',
'#title' => t('Exclude the master (default) display from lists.'),
'#default_value' => isset($settings['skip_default']) ? $settings['skip_default'] : 1,
);
$form['skip_empty'] = array(
'#type' => 'checkbox',
'#title' => t('Do not output view if no rows are detected'),
'#default_value' => isset($settings['skip_empty']) ? $settings['skip_empty'] : 0,
);
$form['skip_disabled'] = array(
'#type' => 'checkbox',
'#title' => t('Do not allow selection of disabled views'),
'#default_value' => isset($settings['skip_disabled']) ? $settings['skip_disabled'] : 0,
);
$form['sort_views'] = array(
'#type' => 'checkbox',
'#title' => t('Sort the views by title'),
'#default_value' => isset($settings['sort_views']) ? $settings['sort_views'] : 1,
);
return $form;
}