Hello @uponity
Thank you very much for using our plugin.
My apologies for the confusion. We are editing the FAQ entries because we modified the implementation of global variables to avoid plugin conflicts.
In previous plugin versions, the shortcode directly creates the global variables, but this has a problem. If another plugin uses a javascript variable with the same name, the global variable will provoke a conflict. The same would happen with global browser variables like window.
With recent plugin versions, the shortcode generates a cff_var object, where the shortcode variables are cff_var properties.
So, if you insert the shortcode:
[CP_CALCULATED_FIELDS id="1" myvar="4"]
You can use it as follows:
fieldname1*cff_var['myvar']
or
fieldname1*cff_var.myvar
Best regards.
Great! Thank you.
For equations it works.
But how can i use the Value to prefill a normal field?
If i try to insert <%cff_var.myvar%> as predefined value i don’t get the Value.
Regards,
Hello @uponity
In the current plugin version, you cannot use variables as fields predefined values directly, but you can assign them at runtime. For example, assuming you have the myvar
variable:
[CP_CALCULATED_FIELDS id="1" myvar="4"]
And you want to use it as the default value of the fieldname123 field.
Insert an “HTML Content” field in the form and enter the following piece of code as its content:
<script>
fbuilderjQuery(document).on('formReady', function(){
getField('fieldname123').setVal(cff_var['myvar']);
});
</script>
Best regards.
Great! Thank you very much!
Works perfectly
Hello @uponity
We are working in a notation that allows to assign Javascript variables as default fields values without ambiguity with plain values.
Best regards.