-
-
Notifications
You must be signed in to change notification settings - Fork 270
Description
Issue Overview
It seems that the "pods_field_dfv_data" filter (similar to "pods_field_pick_data") only manipulate pre-existing values and not newly created ones.
Expected Behavior
Unsure if there is another filter of "post value" creation but one would expect that any display manipulations happening to pre-existing fields will also happen to newly created ones.
Current Behavior
As it currently stands, the newly created field entry will pick the value of the field that is set in the "Title Field" under the "Advanced Options" tab of that related pod.
Steps to Reproduce (for bugs)
To make it convenient, below is the code as a test plugin.
`<?php
/*
Plugin Name: Newly Added Field Display Test
Plugin URI:
Description:
Version: 0.0.0
Author: Ethan Phoenix
Author URI: http://www.ethanphoenix.tk
*/
// don't call the file directly
if ( !defined( 'ABSPATH' ) ) exit;
add_action( 'plugins_loaded', 'ethansAddon_extend_safe_activate');
function ethansAddon_extend_safe_activate() {
if ( defined( 'PODS_VERSION' ) ) {
// MANIPULATING FIELD DISPLAY
add_filter('pods_field_dfv_data', 'combobox_display_data', 1, 6);
function combobox_display_data($data, $args, $attributes){
switch ($data['fieldConfig']['name']) {
case 'country':
foreach ($data['fieldItemData'] as $i=>$val) {
$dataid = $data['fieldItemData'][$i]['id'];
$countryName = pods_field_display('country', $dataid, 'name', true);
$data['fieldItemData'][$i]['name'] = "{$countryName} This text is being added because of a filter but only to an already existing values.";
}
break;
};
return $data;
}
}
}`
below image shows a selected value which already existed in the table and thus the text "This text is being added because of a filter but only to an already existing values." is being added to the value.
this image shows a newly added value "Canada" but as you can see it didn't pass the aforementioned filter and thus only shows the "default" value (a set in the "Title Field" in the related pod's setup screen):
and here you can see that it does apply but AFTER the entry has been added and we refreshed the page:
Possible Solution
Either add another "post add" filter or inject the filter again after adding a new value.
WordPress Environment
WordPress Version: 4.9.8
PHP Version: 7.0.31
MySQL Version: 5.7.23
Server Software: Apache
Your User Agent: Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:52.0) Gecko/20100101 Firefox/52.0
Session Save Path: C:/Bitnami/WORDPR~1.8-0/php/tmp
Session Save Path Exists: Yes
Session Save Path Writeable: Yes
Session Max Lifetime: 1440
Opcode Cache:
Apc: No
Memcached: No
OPcache: Yes
Redis: No
Object Cache:
APC: No
APCu: No
Memcache: No
Memcached: No
Redis: No
WPDB Prefix: wp_
WP Multisite Mode: No
WP Memory Limit: 40M
Pods Network-Wide Activated: No
Pods Install Location: C:\Bitnami\wordpress-4.9.8-0\apps\wordpress\htdocs\wp-content\plugins\pods/
Pods Tableless Mode Activated: No
Pods Light Mode Activated: No
Currently Active Theme: Twenty Seventeen
Currently Active Plugins:
Newly Added Field Display Test: 0.0.0
Pods - Custom Content Types and Fields: 2.7.9
</details>
## Pods Package Export (helpful!)
{"meta":{"version":"2.7.9","build":1534559383},"pods":{"5":{"id":5,"name":"country","label":"Countries","description":"","type":"pod","storage":"table","object":"","alias":"","fields":{"name":{"id":6,"name":"name","label":"Name","description":"","help":"","class":"","type":"text","weight":0,"pick_object":"","pick_val":"","sister_id":"","required":"1","unique":"0","text_repeatable":"0","text_allowed_html_tags":"strong em a ul ol li b i","text_max_length":"255","text_placeholder":""},"flag":{"id":7,"name":"flag","label":"Flag","description":"","help":"","class":"","type":"file","weight":1,"pick_object":"custom-simple","pick_val":"","sister_id":"","required":"0","unique":"0","file_format_type":"single","file_uploader":"plupload","file_attachment_tab":"upload","file_edit_title":"1","file_show_edit_link":"1","file_linked":"1","file_limit":"0","file_restrict_filesize":"10MB","file_type":"images","file_field_template":"rows","file_add_button":"Add File","file_modal_title":"Attach a file","file_modal_add_button":"Add File","file_wp_gallery_output":"0","file_wp_gallery_link":"post","file_wp_gallery_columns":"1","file_wp_gallery_random_sort":"0","file_wp_gallery_size":"thumbnail","pick_post_status":["publish"],"admin_only":"0","restrict_role":"0","restrict_capability":"0","hidden":"0","read_only":"0","roles_allowed":["administrator"],"file_allowed_extensions":""}},"show_in_menu":"1","label_singular":"Country","pod_index":"name","hierarchical":"0","ui_style":"post_type","ui_actions_enabled":["add","edit","duplicate","delete"],"ui_reorder_field":"menu_order","ui_fields_manage":{"0":"name","2":"modified"}},"8":{"id":8,"name":"event","label":"Events","description":"","type":"pod","storage":"table","object":"","alias":"","fields":{"name":{"id":9,"name":"name","label":"Name","description":"","help":"","class":"","type":"text","weight":0,"pick_object":"","pick_val":"","sister_id":"","required":"1","unique":"0","text_repeatable":"0","text_allowed_html_tags":"strong em a ul ol li b i","text_max_length":"255","text_placeholder":""},"country":{"id":10,"name":"country","label":"Country","description":"","help":"","class":"","type":"pick","weight":1,"pick_object":"pod","pick_val":"country","sister_id":"","required":"1","unique":"0","pick_format_type":"multi","pick_format_single":"list","pick_format_multi":"list","pick_allow_add_new":"1","pick_taggable":"0","pick_show_icon":"0","pick_show_edit_link":"1","pick_show_view_link":"0","pick_limit":"0","pick_user_role":[],"pick_post_status":["publish"],"admin_only":"0","restrict_role":"0","restrict_capability":"0","hidden":"0","read_only":"0","roles_allowed":["administrator"],"pick_select_text":"","pick_table_id":"","pick_table_index":"","pick_display":"","pick_where":"","pick_orderby":"","pick_groupby":""}},"show_in_menu":"1","label_singular":"Event","pod_index":"name","hierarchical":"0","ui_style":"post_type","ui_actions_enabled":["add","edit","duplicate","delete"],"ui_reorder_field":"menu_order","ui_fields_manage":["name"]}}}
## Workaround or Alternate Solution Until Bug is Addressed
<!-- We will complete this section, or if you've already found a workaround, -->
<!-- you can add it here -->
## Related Issues and/or PRs
<!-- List related issues or PRs against other branches: -->