Form Transients

This Mastermind tip is contributed by Rob Levine (@RobL) from the Formidable Slack Community. Thank you Rob!

Rob was experiencing a caching issue when programmatically adding an option to a checkbox. In the Slack community's General channel, he posted:

 ...I'm using a filter to update the Formidable fields table (frm_fields).  I'm manually adding an option to a checkbox.  However, regardless of what cache I clear, the change isn't seen in the UI until I simply walk away for several hours and then refresh the page.   If there is a cache, how can I force it to clear out?

After some experimentation, Rob later posted the solution he discovered:

I did a little more testing and found the answer.  I realized that if I go into the form itself in the Formidable admin and make the same change the effect is immediate, so there has to be caching going on.  I then pored over FrmField.php and tried every caching related command I could find that is used when a field is updated and finally found that one that worked for me.  If I call FrmField::delete_form_transient( $form_id ); the cache (or whatever we want to call it) is cleared.  All hail trial and error!

Kudos to RobL for this great catch!

Reader Interactions

Leave a Reply

Your email address will not be published.