Forums › Forums › Search & Filter Pro › Date UI field in search form causes undefined index error
Tagged: date-field, post meta, undefined-index
- This topic has 12 replies, 2 voices, and was last updated 5 years, 8 months ago by Anonymous.
-
Anonymous(Private) March 21, 2019 at 5:55 pm #205897
I’m working with the S&F Pro plugin on my local env, and have left most of the settings to default. I tried adding a date field block for my search form, and when I try to publish, it causes fatal PHP errors. They all point to the
class-search-filter-post-data-validation.php
file in the plugin lines 221/222:PHP message: PHP Notice: Undefined index: date_use_dropdown_month in /[my-project]/wp-content/plugins/search-filter-pro/admin/includes/class-search-filter-post-data-validation.php on line 221
The error goes away if I do not include the date range option in my form using the UI that’s available. If I keep the date field, but check the “Use dropdown for Year/month” checkboxes, the error also resolves.
It’s only if I don’t want to use dropdowns that it seems to cause fatal errors. I do want to use text fields like the way the non-PRO search & filter has for the date range.
I’m on WP 5.1 if it helps. Thanks.
Trevor(Private) March 22, 2019 at 3:54 am #205928If you have some dates already stored, you may need to check what data is stored in that field. To easily do this, take a look at this screenshot of my dev site admin screen for a form:
https://www.screencast.com/t/PiQW6EnVVK
Set your field up i the same way and click the Browse Values button to see what is stored. The dates must be in the format shown in my screenshot.
What version of PHP are you using, and can you confirm you are using v2.4.6 of our plugin?
Anonymous(Private) March 22, 2019 at 2:41 pm #206008Hi Trevor,
I am using PHP 7.1.15 and yes, I’m using 2.4.6 of the S&F Pro plugin. I checked my database because I couldn’t find the value by setting up the post meta field like your example – and checked for a meta value of ‘first_date_from’ and ‘date_use_dropdown_month’, both with and without the preceding underscore – and those keys don’t exist in my database’s post meta.
Would creating the key for
_first_date_from
with an empty value resolve the issue?Thanks.
Anonymous(Private) March 22, 2019 at 2:47 pm #206010If it helps, I was using the non-PRO S&F plugin previously before I switched to PRO. I don’t know if perhaps the free version of the plugin saves things in the database for the date range field that may conflict with trying to set up a date range field in PRO?
I was replacing the shortcode from the free version with the pro version, and both forms should have a date range. In the case of the free version, I had the date range set up as two text fields for the from/to date, format mm/dd/yyy.
Thanks.
Anonymous(Private) March 28, 2019 at 3:17 pm #206788Thank you for all of your time. While I still get the error, I’m going to just use the date range field with the “Use dropdown for Year/month” checkboxes checked. That seems to work fine. To re-create the fatal error, all you’d have to do is set up the Post Date field, and set it to “Date Range” and don’t fill out anything else for that field. Try to publish the form and you should see the undefined error.
Thanks again!
Anonymous(Private) March 29, 2019 at 3:07 pm #206911I have 6 fields.
– Search
– Post Type:
Set to “Dropdown” and I changed the “All Items” to “All”
– Category:
Set to “Dropdown” with all items set to “All” and display count/hide empty terms/hierarchical/Include children checked
– Post Date:
Set to “Date Range” with Date Formar 03/28/2019 and only the “Use dropdown for year/month” checked
– Sort Order:
Set to “Dropdown” and All Items as “Relevance”. Sort options set as Title/Desc and Date/Desc
– Submit button.I decided to simplify and try another test so I set up a new form. This time I didn’t touch any of the settings, and I just added a Search field and a Date field. Set the Date field to date range and didn’t mess with anything else. All the other settings on the Date field are empty or at their defaults. As soon as I tried to publish, I got the error again.
The
date_use_dropdown_year
is specific to the PRO plugin, I searched my customized WP theme to make sure we didn’t have the same meta key for something else and we don’t.I also switched to a default WP theme (Twenty Sixteen) to see if it was theme related. I still get the same error.
-
AuthorPosts