Commit 96cf2c8b authored by Chris Graham's avatar Chris Graham
Browse files

Fixed MANTIS-4302 (Consider key-val format for DISPLAY of CPFs that use it)

parent b5b8ff2e
Loading
Loading
Loading
Loading
+3 −1
Original line number Diff line number Diff line
@@ -320,7 +320,7 @@ NB: When adding there is no UI if 'AUTO_INCREMENT' was used.
! Special default values
| Options are delimited by "|" (e.g. "This|That|Other"), with the real default value coming first. If you want the real default to be blank, start the list with a blank (it won't allow actual selection unless the list is set as non-required).

You can also do like "a=This|b=That|c=Other" if you need the saved values to be different from the values displayed for selection.
You can also do like "a=This|b=That|c=Other" if you need the saved values to be different from the values displayed for selection, and optionally also displayed on the site. This is called "key-val format".

You can input a pathname relative to a [tt].csv[/tt] file (relative to base directory), if the non-bundled Nested CPF CSV Lists addon is installed.
|-
@@ -329,6 +329,8 @@ You can input a pathname relative to a [tt].csv[/tt] file (relative to base dire

[tt]dynamic_choices[/tt] (whether to feed custom values back in as possible selections for others; default is off)

[tt]display_val=on|off[/tt] (when key-val format is used this sets whether it also influences display not just input)

[tt]value_remap=none|country[/tt] (if set to country then the full country names are shown for ISO country codes in the list options; default is none)

[tt]auto_sort=on|off[/tt] (whether to sort the list options; default is off)
+8 −0
Original line number Diff line number Diff line
@@ -111,6 +111,14 @@ class Hook_fields_list
        if (is_object($ev)) {
            return $ev;
        }

        if (option_value_from_field_array($field, 'display_val', 'off') == 'on') {
            $map = $this->get_input_list_map($field, false);
            if (isset($map[$ev])) {
                $ev = $map[$ev];
            }
        }

        return comcode_to_tempcode($ev, null, true);
    }

+1 −1
Original line number Diff line number Diff line
@@ -87,7 +87,7 @@ class Hook_fields_list_multi
                    $default = preg_replace('#^(=.*)?\|#U', '', $default); // Get key of blank option
                }
                $default = preg_replace('#\|.*$#', '', $default); // Remove all the non-first list options
                $default = preg_replace('#=.*$#', '', $default); // Get key of first
                //$default = preg_replace('#=.*$#', '', $default); // Get key of first      key->val support does not exist for this field type, #4301
            }
        }
        return array('long_unescaped', $default, 'long');