ChronoEngine.com homepage

Forums

Access Table Data

G
grantdigital posted Sep 7, 2020 at 05:48
I am testing out Chronoforms 7 and I trying to add PHP in a table to output some data calculated in PHP.
Using the same syntax as with Chronoforms 6 "$this->get('table.row.Model.field')" returns nothing. So I looked at the examples and it just used '{var:Model.field}' to display them but when I try "$this->get('Model.field')" I just get the data from first row. I also tried to get the key but always returned the 1st row.

In the screenshot the 'Format Date column is where I have the 'HTML field' with the PHP code, the first link is using the {var:XXX} syntax and 2nd line is trying to get from PHP. Why can't I get current row in PHP now?

https://i.imgur.com/D6FlqPS.jpg
H
healyhatman posted Sep 7, 2020 at 12:35
$this->get('tableName.row.Model.field') should definitely work. If it doesn't, try just print_r($this->get('tableNameGoesHereDontLiterallyTypeThis.row')) see what the data shows.
Max_admin posted Sep 7, 2020 at 15:40
where do you call the PHP code and how ?
Max
ChronoForms developer...
ChronoForms v8 is out, do you have any suggestions? please let us know.
G
grantdigital posted Sep 7, 2020 at 23:13
I am using HTML block with 'Run PHP' in Advanced settings.
Also trying var_dump($this->get('list.row')); returns NULL. In the PHP code it just getting the first row.
Max_admin posted Sep 8, 2020 at 03:06
what is the name of your "Read Data" ? to get the name you need to move the mouse over the "Read data" action label, it will appear in a tooltip
Then use that name in the get() function call!
"list" will not return anything unless it's the name of the Read data!
Max
ChronoForms developer...
ChronoForms v8 is out, do you have any suggestions? please let us know.
G
grantdigital posted Sep 8, 2020 at 03:39
the 'list' was the name of the table element and "var_dump($this->get('read_banners.row'));" also returns null.
I can find to get the current row in ChronoForms7. In v6 it was done from the table element.
As I said originally examples just use 'Model.field' to display the data in a table. that work when doing '{var:Model.field}' But does not in PHP code. I have tried the following

Model.field = always first row's field
table.key = always first row's key (tied to use this to access the data in array)
table.row = NULL
read_data.row = NULL
Here is my PHP code and screenshots of the output. Note the boxed data is the same in every row
{var:list.key}|{var:Banner.name}<br>
<pre>
<?php
var_dump($this->get('Banner.name'));
var_dump($this->get('list.key'));
var_dump($this->get('list.row'));
var_dump($this->get('read_banners.row'));
?>
</pre>
https://i.imgur.com/N82yfmO.jpg
https://i.imgur.com/8lh0GUQ.jpg
Max_admin posted Sep 8, 2020 at 03:46
in v7 you get the data from the "Read data", you should try:
$this->get('read_banners')
but inside the table row you can use {var:Model.field_name}
Max
ChronoForms developer...
ChronoForms v8 is out, do you have any suggestions? please let us know.
G
grantdigital posted Sep 8, 2020 at 03:48
Using $this->get('read_banners') gives me the entire data from the database. I want the data from the current row so I can do calculations on that data. Currently, I have no way of getting the current row's data
Max_admin posted Sep 8, 2020 at 15:47
if you want to get the current row data inside the table then use {var:Model.field} or $this->get("Model.field") inside the HTML view!
Max
ChronoForms developer...
ChronoForms v8 is out, do you have any suggestions? please let us know.
G
grantdigital posted Sep 9, 2020 at 22:58
As I said, in the PHP that always just returns the first row which you can see from the first line in the boxed text in my above screenshots. That is using the PHP code var_dump($this->get('Banner.name'));
G
grantdigital posted Sep 15, 2020 at 00:41
Yes in the screenshot the 'Format Date' column uses the below code. Everything in the PHP code only every returns the first row in the data, not the current row. I tried every combination I can think of but none work correctly.
{var:list.key}|{var:Banner.name}<br>
<pre>
<?php
var_dump($this->get('Banner.name'));
var_dump($this->get('list.key'));
var_dump($this->get('list.row'));
var_dump($this->get('read_banners.row'));
?>
</pre>
S
shahabpk posted Sep 19, 2020 at 16:38
Hi Max
As grantdigital pointed out, $this->get("Model.field") inside the HTML view with PHP enabled prints the first row data in all all rows of a Table List column in Chronoform 7.0.2
S
shahabpk posted Sep 28, 2020 at 08:47
Hi grantdigital,
could you find a solution to this?
G
grantdigital posted Sep 30, 2020 at 00:00
So I just checked with v7.0.4 and I still have the same issue.
Has no dev even checked this as no hard to replicate the issue.
Max_admin posted Oct 8, 2020 at 02:29
Answer
this should be fixed in 7.0.5
Max
ChronoForms developer...
ChronoForms v8 is out, do you have any suggestions? please let us know.
E
Elita posted Dec 20, 2020 at 10:41
hello to all involved in this conversation- has anybody resolved this? If yes, could you type the guidlines on how to call a PHP function in the table list?
Max_admin posted Dec 22, 2020 at 00:20
You can not call an action in the table view, you may add an HTML view and inside that enable the PHP support behavior!
Max
ChronoForms developer...
ChronoForms v8 is out, do you have any suggestions? please let us know.
E
Elita posted Dec 22, 2020 at 08:52
No, sorry Max, I cannot. Actually I cannot do nothing in table views since there is a bug.
in Connectivity form in table list only FIRST (built-in) table column works. In other you cannot do NOTHING!!!
Please, fix this ASAP.
Max_admin posted Dec 23, 2020 at 03:00
fixed in the next update!
Max
ChronoForms developer...
ChronoForms v8 is out, do you have any suggestions? please let us know.
I
ieraora posted Aug 15, 2021 at 04:38
I think it's an error also in dropdown inside table.
As images, I get value in text fiend and in dropdown, but in last the selection is wrong
http://www.generaphoto.com/temp/Imm_01.jpg
http://www.generaphoto.com/temp/Imm_02.jpg
http://www.generaphoto.com/temp/Imm_03.jpg
This topic is locked and no more replies can be posted.

2Checkout.com

2CheckOut.com Inc. (Ohio, USA) is an authorized retailer for goods and services provided by ChronoEngine.com