Overrides SelectionBase::settingsForm().
Overrides SelectionBase::settingsForm
public static function settingsForm(&$field, &$instance) {
// Merge in default values.
$instance['settings']['handler_settings'] += array(
'filter' => array(
'type' => '_none',
),
);
// Add user specific filter options.
$form['filter']['type'] = array(
'#type' => 'select',
'#title' => t('Filter by'),
'#options' => array(
'_none' => t('- None -'),
'role' => t('User role'),
),
'#ajax' => TRUE,
'#limit_validation_errors' => array(),
'#default_value' => $instance['settings']['handler_settings']['filter']['type'],
);
$form['filter']['settings'] = array(
'#type' => 'container',
'#attributes' => array(
'class' => array(
'entity_reference-settings',
),
),
'#process' => array(
'_entity_reference_form_process_merge_parent',
),
);
if ($instance['settings']['handler_settings']['filter']['type'] == 'role') {
// Merge in default values.
$instance['settings']['handler_settings']['filter'] += array(
'role' => NULL,
);
$form['filter']['settings']['role'] = array(
'#type' => 'checkboxes',
'#title' => t('Restrict to the selected roles'),
'#required' => TRUE,
'#options' => array_diff_key(user_role_names(TRUE), drupal_map_assoc(array(
DRUPAL_AUTHENTICATED_RID,
))),
'#default_value' => $instance['settings']['handler_settings']['filter']['role'],
);
}
$form += parent::settingsForm($field, $instance);
return $form;
}