Forums
How to write to {global:myfield}
$this->globals("myfield")
Hi Max
let me know why {global:local} or {globals:local} show me the current value "1" in html-box
and in php-box echo $this->global['local'];
or echo $this->globals['local'];
doesn't show anything
kind regards
sorry I already realized of my mistake echo $this->globals('local');
with round brackets ;-)
Hi Max when Try to update global variable from my form I get this error
$this->globals('local')=2;

Hi teldrive
It's not possible to update the variables in the globals, you need to create a form variable and update it if you need:
$this->set("local", $this->globals("var"));
$this->get("local"); // this is how you get it now
$this->set("local", "new"); // now you can change it
Hi Max
I must be missing something, I tried all this but I couldn't change the global variable from "1" to "2"
$this->set("local", $this->globals("local"));
$this->data['local']=$this->get("local");
echo $this->data['local'];
$this->set("local", "2");
echo "first attempt ".$this->globals("local");
$this->set( $this->globals("local"),"2");
echo "second attempt ".$this->globals("local");
$this->data['local']=2;
$this->set( $this->globals("local"),$this->data['local']);
echo "third attempt ".$this->globals("local");
thanks in advance
The global variable can NOT be changed, you can only get it and use it 😉
Ok , understood then you have to change the concept "global variable" by "global constant"😊
by the way should be very interesting to change it in order to avoid to create a table to make easier programming
Yes, that would fit better 😊
But why did you need to change the global variable ? why not use a local variable ?
I have an web-app to change plates database for an ANPR system, by default (for security reasons) web app only work with private IP address
If I need to test a new feature remotely I change global variable to use IP public(only for administrator) in a settings web page. Of course I can use settings table to do it, but I was exploring the possibility to use global variable to do it ;-)
I think you can do this with a local variable at the form itself, but I can not imagine it well to try it
Wehen I try :
$this->set("local", $this->globals("var"));
I get an error : Call to undefined method G3\A\E\Chronoforms\L\Page::globals()
(CF7 , PHP 8.2, MariaDB 10.6)
Where do you call it ? in a PHP action ?
Yes, from a PHP-action Page 1
which v7 version do you have installed ? and which Joomla ?
<version>7.0.12</version>
Joomla 5.2.5