5 * Definition of views_handler_argument_field_list.
9 * Argument handler for list field to show the human readable name in the
12 * @ingroup views_argument_handlers
14 class views_handler_argument_field_list extends views_handler_argument_numeric {
16 * Stores the allowed values of this field.
20 var $allowed_values = NULL;
22 function init(&$view, &$options) {
23 parent::init($view, $options);
24 $field = field_info_field($this->definition['field_name']);
25 $this->allowed_values = list_allowed_values($field);
28 function option_definition() {
29 $options = parent::option_definition();
30 $options['summary']['contains']['human'] = array('default' => FALSE, 'bool' => TRUE);
35 function options_form(&$form, &$form_state) {
36 parent::options_form($form, $form_state);
38 $form['summary']['human'] = array(
39 '#title' => t('Display list value as human readable'),
40 '#type' => 'checkbox',
41 '#default_value' => $this->options['summary']['human'],
42 '#dependency' => array('radio:options[default_action]' => array('summary')),
47 function summary_name($data) {
48 $value = $data->{$this->name_alias};
49 // If the list element has a human readable name show it,
50 if (isset($this->allowed_values[$value]) && !empty($this->options['summary']['human'])) {
51 return field_filter_xss($this->allowed_values[$value]);
53 // else fallback to the key.
55 return check_plain($value);