-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathac-editing-value.php
More file actions
46 lines (39 loc) · 1.07 KB
/
ac-editing-value.php
File metadata and controls
46 lines (39 loc) · 1.07 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
<?php
/**
* This hook allows you to alter the value that is retrieved for editing before it is displayed in the editable.
*/
function ac_editing_value_example_usage(
$value,
AC\Column\Context $column,
$id,
AC\TableScreen $table,
AC\Type\ListScreenId $list_screen_id
) {
return $value;
}
add_filter('ac/editing/input_value', 'ac_editing_value_example_usage', 10, 5);
// Or anonymous function
add_filter('ac/editing/input_value', static function (
$value,
AC\Column\Context $column,
$id,
AC\TableScreen $table,
AC\Type\ListScreenId $list_screen_id
) {
return $value;
}, 10, 5);
/**
* Example to get a nested value from an associative array. You need to parse it back when saving the value with the hook `acp/editing/save_value`
*/
add_filter('ac/editing/input_value', static function (
$value,
AC\Column\Context $column,
$id,
AC\TableScreen $table,
AC\Type\ListScreenId $list_screen_id
) {
if ($column instanceof AC\Column\CustomFieldContext) {
$value = $value['sub_key'];
}
return $value;
}, 10, 5);