I don't understand the inner workings of cfv6 when loading a form to edit a record. In previous versions it was pretty straight forward. Now I'm disappointed, probably my fault, because I don't see a consistent way to access the record data.
I followed the manual and used a Read Data action to load a record (First matching record, model name: myRecord).
In the Display Section action Data provider -> {var:read_data20.myRecord}.
Now I expected to find the record data in the data object (the old style: $this->data) but...
In an HTML object in the designer I put:
The 1st line prints nothing.
The 2nd one prints
but not my record data.
The 3rd one gives an undefined index: myRecord.
Anyway some of the fields (let's say the standard input elements) are populated. Other elements are not.
E.g.:
- in a Calendar in the html code I can see that the value attribute is assigned but the displayed input element is blank.
In the properties of the calendar I added something to the Value property.
{data:myRecord.myDataField} or {var:read_data20.myRecord.myDataField} do not work, the calendar is still empty.
- in a repeater I expected to use something like {data:myRecord.myrepeaterField} as a Data Provider, but I found out I had to use {var:read_data20.myRecord.myrepeaterField}.
- It is very simple to json encode the repeater values (Save Data action in Data override on Insert):
myrepeaterField:{data.jsonen:myrepeaterField}, but json decode it in the read data action is very different, the only working solution I found is a php action with the following code:
$this->set("read_data20.myRecord.myrepeaterField", json_decode($this->get("read_data20.myRecord.myrepeaterField"), true));
Since all that messes up the code and simplicity of cf, there must be something I'm doing wrong or that I don't understand.
Can somebody help?
Thank you
maxx
I followed the manual and used a Read Data action to load a record (First matching record, model name: myRecord).
In the Display Section action Data provider -> {var:read_data20.myRecord}.
Now I expected to find the record data in the data object (the old style: $this->data) but...
In an HTML object in the designer I put:
{data.pr:myRecord}
<?php pr($this->data); ?>
<?php pr($this->data['myRecord']); ?>
The 1st line prints nothing.
The 2nd one prints
[option] => com_chronoforms6
[chronoform] => evento
...
but not my record data.
The 3rd one gives an undefined index: myRecord.
Anyway some of the fields (let's say the standard input elements) are populated. Other elements are not.
E.g.:
- in a Calendar in the html code I can see that the value attribute is assigned but the displayed input element is blank.
In the properties of the calendar I added something to the Value property.
{data:myRecord.myDataField} or {var:read_data20.myRecord.myDataField} do not work, the calendar is still empty.
- in a repeater I expected to use something like {data:myRecord.myrepeaterField} as a Data Provider, but I found out I had to use {var:read_data20.myRecord.myrepeaterField}.
- It is very simple to json encode the repeater values (Save Data action in Data override on Insert):
myrepeaterField:{data.jsonen:myrepeaterField}, but json decode it in the read data action is very different, the only working solution I found is a php action with the following code:
$this->set("read_data20.myRecord.myrepeaterField", json_decode($this->get("read_data20.myRecord.myrepeaterField"), true));
Since all that messes up the code and simplicity of cf, there must be something I'm doing wrong or that I don't understand.
Can somebody help?
Thank you
maxx