Open EthanPhoenix opened 5 years ago
The pods_field_dfv_data
filter is only called on page load in order to initialize the starting values for the field, so it was not designed for this.
When you add a record using the "Add New" button, new values are created on the select box dynamically in the browser. I think we can come up with a clean way to do what you're trying to do but it will likely be a job for Javascript and not PHP.
I'm going to close this one in favor of your other ticket, #5091. A proper solution should handle both cases.
On second thought: re-opening this because there still needs to be a way to hit a filter on add new on the server side, in order to look up custom data. A new filter is called for.
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' ) ) {
}`
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
Pods Package Export (helpful!)
Workaround or Alternate Solution Until Bug is Addressed
Related Issues and/or PRs