- This topic has 3 replies, 2 voices, and was last updated 9 years, 5 months ago by .
- You must be logged in to reply to this topic.
I’ve noticed that when using the BePro Vehicles Addon, the
<select> fields don’t appear to be working correctly.
It seems as though every time the first non-placeholder option is selected (
<option value="0">), the value isn’t properly saved into the bepro_listings_vehicle database. I first noticed that, when editing the fields by way of the form found in the BuddyPress profile page, any vehicle dropdown field I changed to the first option would not update in the BePro_Listings_Vehicles database. Any that were changed to the second+ option updated correctly.
I thought this might be due to modifications I made to the plugin, but I’ve just tested it on a fresh install of Be_Pro, Be_Pro_Vehicles, BePro_Authors, and Buddypress on a different theme and was able to replicate the issue. What’s more, on this new install I was unable to get these fields to save correctly upon listing creation (as opposed to editing the listing) and I know I have been able to get these fields to work previously.
For the record, this appears to only affect the BePro_Listings_Vehicles database, not the BePro_Listings_Vehicle_Types database, as I was able to change the Status field to each different value succesfully.
I think this might have something to do with the array reference key starting at 0 and the database interpreting that 0 as a null or empty value. This is just a theory, as I’ve been coding all day and wasn’t about to jump into this new challenge with half an hour left to work. I leave the issue in your capable hands.
Even if you don’t update the plugin right away, I would love to know a fix for this issue ASAP, as my site focuses on vehicle listings.
Our team is investigating this issue and will update this post with an answer asap
BePro Software Team
Figured it out today, the problem lies in the PHP
empty() function evaluating 0 as false.
Every time the post data contained an argument of 0,
update_vehicle_listing() would view it as empty and save the empty string into the database rather than the 0. Made a few modifications to use
empty() and everything seems to be working correctly.
Thanks for sharing the fix. We will implement it into the next release of the addon
BePro Software Team
Stay up to date on web design and development trends. Also receive updates on video tutorials, services, deals, products, and discounts offered by the BePro Software Team. to sign-up for our newsletter today.