How do I use string values in field calculations?

By: Howard Fore | Asked: 07/09/2022
ForumsCategory: General questionsHow do I use string values in field calculations?
Howard Fore asked 2 years ago
I have a set of checkboxes with long values for the form filler and separate short values for the person managing the input. I have a second field that I want to conditionally set to 1 if the form filler checks any of a subset of the checkboxes. So, "if the user selected checkbox 1 or checkbox 3 or checkbox 4 then set the value of field xyz to 1" is what I want to put into the calculation of text field xyz. But how do I use the string values from the checkbox set in the calculation. All the examples I've seen are using numeric values and when I try string values in those comparisions (like below) I get nothing. What I've tried: (format from FF docs): (([1215] == 'Alpha' || [1215] == 'Charlie') || [1215] == 'Delta') ? (1) : (0)    (format from a random blog post): if ( [1215] == 'Alpha' || [1215] == 'Alpha' || [1215] == 'Delta' ) { '1' }   
Bobby Clapp replied 2 years ago

In the example above is "Alpha" the long value or the short value (presuming short is the separate value)?

Fidan Jovanov replied 1 year ago

I am having the same issue. Has anyone found a solution?

I have checkboxes with string values and I want another field to show Yes if a certain checkbox value is selected.

1 Answers
Victor Font answered 1 year ago
You don't say where you've placed the code, so I'm assuming it's a default value calculation for field 2. Default value calculations can be either "text" or "math" based. Text based calculations are used for concatenating strings. Math based calculations are used to produce computational results. Determining a string value with conditional PHP code needs to be done in a custom shortcode you create or custom jQuery.

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