{var:var_name} not working in chronoforms V7

Ron 10 Feb, 2023
Hello

I have a PHP code the output of which I need to get as var: but I have seen that it does not work in V7. I am using {var:var_name} the name that I give to my PHP field.
could someone please tell me the right way to go about it?

Thanks
Ron
wbuk 12 Feb, 2023
Several possibilities:

Did you do a "return $value;" at the end of your PHP field?

Did you have a {fn:var_name} before the {var:var_name}? You need to run the function prior to calling the variable output from the function.

Have you double check all the spellings of your functions and variables?

If you do a {debug:}, is the function var_name visible in the debugging code?
Ron 12 Feb, 2023
Hello wbuk.

Thanks for your post. I am sorry I did not understand your post.

Did you do a "return $value;" at the end of your PHP field?

Did you have a {fn:var_name} before the {var:var_name}?



{fn:var_name} before the {var:var_name} Could you please give me an example ?

Thanks
Ronn
wbuk 12 Feb, 2023
Basically in your PHP field block, you should have something like this:

Function name "Hello":

var $foo = "Hello world";
return $foo;


Then on your HTML page, you do:

{fn:Hello}
{var:Hello}


Result:

Hello world

The {fn:Hello} has to come before {var:Hello}
Ron 12 Feb, 2023
Hello

How do I show an image here ? I want to show my screenshot.

Ron
wbuk 12 Feb, 2023
You have to upload it somewhere else (I used imgbb) then type:

{img}URL of image here{/img}

Change curly brackets to square brackets.
Ron 12 Feb, 2023
{var:var_name} not working in chronoforms V7 image 1

How to use the var output here

Ron
Ron 12 Feb, 2023
I don't understand but the image shows only the URL.

Sorry.

Ron
wbuk 12 Feb, 2023
That's fine we still can just open the URL.

Ah apologies I didn't know you were using the Advanced Form mode (I was using the Connectivity mode). If so you don't need the {fn:var_name}. Basically to get the output, you just use {var:isd} anywhere, as long as it's on the same page.

{var:isd}
Ron 12 Feb, 2023
Thanks. I tried using the {var:isd} it did not work. I did not know that PHP has to be on the same page. I am going to try that out.
Ron
Rollo71 13 Feb, 2023
if your php module is called "php_pippo"and returns a value like this example,

var $rv = "Hello world";
return $rv;

try with {var:php_pippo}
TGeier 13 Feb, 2023
Try

to get {var:var_name} in php

...

-> $this->set('var_name', 'your value');
You need to login to be able to post a reply.

VPS & Email Hosting 20% discount
hostinger