Formidable Views - Create a Conditional Statement To Check "Departure Date" Against Today's Date

By: Shawn Wilson | Asked: 01/07/2024
ForumsCategory: Code HelpFormidable Views - Create a Conditional Statement To Check "Departure Date" Against Today's Date
Shawn WilsonShawn Wilson asked 3 months ago
Hello All,  I am brand new to the world of Formidable Forms and Views.    I have been pouring over the docs and videos trying to figure out a way to check a date field a user selects in my form against the actual date and update a column on my table view. Essentially this is wat i Want to do:   If todays date is less than the departure than the departure date the column should read "ACTIVE" If the departure date is Greater than or Equal to the departure date the column should read "EXPIRED"  I'm just not too sure how I can work this out, there has to be a way, i just can't think of it or find anything about it!
1 Answers
Rob LeVineRob LeVine answered 3 months ago
Honestly, I'm a little surprised I couldn't figure out a straightforward, out-of-the-box solution either. One of the easier alternate solutions is to create a custom shortcode and pass it the value in the date field and then the shortcode compares the date to the current date and returns ACTIVE or EXPIRED. It will only be a few lines of PHP code.
Shawn WilsonShawn Wilson replied 3 months ago

So i went a bit of a different direction here, I essentially created 2 views, one for active and one for expired. Then Filtered my responses using greater than and less than equal to conditionals checking against the current date [date] and created a toggle on the page to show Active and Expired results. Not as easy as one view fits all but i do like how it makes it more "interactive" and doesn't bloat the view with all records when we are really only chasing the active entries.

Does what i need it to, bit more work than I wanted but impressed with the final results.

Making the Best WordPress Plugin even better - Together

Take on bigger projects with confidence knowing you have access to an entire community of Formidable Experts and Professionals who have your back when the going gets tough. You got this!
Join the community