Hello! I'm not frequent to CF but I found v6 to be absolutely awesome! Though, I can't load records into a form for the user to modify their past saved inputs.
I've tried with DB Read, with php functions and {var:function_name} inside the Value Field, but fields won't load. I can't find a clear answer for this neither on FAQs or Forum. I'm sure this should be very easy and I don't need CC, but just can't figure out how.
Documentation for CF5 recommends to add custom code on the "conditions box", but this box is not literally present inside DB Read. I used this code
Is there an straightforward post or FAQ for this?
I've tried with DB Read, with php functions and {var:function_name} inside the Value Field, but fields won't load. I can't find a clear answer for this neither on FAQs or Forum. I'm sure this should be very easy and I don't need CC, but just can't figure out how.
Documentation for CF5 recommends to add custom code on the "conditions box", but this box is not literally present inside DB Read. I used this code
<?php return array('nombre_organizacion' => $form->data['nombre_organizacion']); ?> inside the "fields to retrieve" box; the debugger shows a correct call for the data, but then I don't know how to load that data into the input field.
Is there an straightforward post or FAQ for this?
Hi xoles,
If there is a correct array of data then it can be set as the form "data provider" under the "display section" action.
a correct array should match the form fields names, so if your form fields names do not have a model name then you can get the correct array from a "read data" with "select type" set to "get first record", and place this in the "data provider" of the "display section":
Best regards,
Max
If there is a correct array of data then it can be set as the form "data provider" under the "display section" action.
a correct array should match the form fields names, so if your form fields names do not have a model name then you can get the correct array from a "read data" with "select type" set to "get first record", and place this in the "data provider" of the "display section":
{var:read_data_name.Modelname}
Best regards,
Max
Now I'm trying to load the filename and call an img src, but can't get the filename to render on a custom html.
I've tried with
Please check my debugger, where the array is being read from db correctly:
I've tried with
{filename}, {Model.filename}, {data:Model.filename}, {var:Model.filename} and even with $form->data["Model"]["file_name"];
Please check my debugger, where the array is being read from db correctly:
[var] => Array
(
[Recursos] => Array
(
[id_recurso] => 4
[user_id] => 352
[created] => 2017-05-13 01:22:57
[modified] => 2017-05-13 01:23:15
[estructura_organizacional] => 20170512230559_xyz-png.png
[nomina] => 8
[voluntarios] => 5
[honorarios] => 6
)
)
Hi zoles,
What is the name of the "read data" action used to read this record ?
The syntax should be then:
Best regards,
Max
What is the name of the "read data" action used to read this record ?
The syntax should be then:
{var:read_data_name.Recursos.estructura_organizacional}
Best regards,
Max
Thanks for the heads up! It works. Now, I'm struggling to keep the file record unmodified when the file field is empty... trying with no luck this two options inside a custom code box after upload and before save DB:
Record is modified with "undefined".
I also tried disabling the file field and only activating it with a previous "want to re-upload" checkbox. But no luck either.
<?php
if(!empty($form->data["estructura_organizacional"]))
{$form->data['estructura_organizacional'] = $form->files['filename'];}
else
{unset($form->data['estructura_organizacional']);}
if ( $form->data['estructura_organizacional'] = "undefined") {
unset($form->data['estructura_organizacional']);
}
?>
Record is modified with "undefined".
I also tried disabling the file field and only activating it with a previous "want to re-upload" checkbox. But no luck either.
Hi xoles,
You will need to clear the file field before the "save data" action, please try this code in a PHP action:
Best regards,
Max
You will need to clear the file field before the "save data" action, please try this code in a PHP action:
if(empty($this->data("field_name"))){
unset($this->data["field_name"]);
}
Best regards,
Max
Hi, thanks for the help, but the record is still being updated as "undefined". Find attached image of boxes order and here the debugger output:
Array
(
[chronoform] => modificar-recursos
[event] => submit
[tvout] => view
[display-section1] => Array
(
[counter] => 1
)
[_counter] => 1
[checkbox14] => 1
[nomina] => 5
[voluntarios] => 1
[honorarios] => 2
[estructura_organizacional] => undefined
[modificar-recursos] =>
)
Array
(
[validate_fields2] => Array
(
[log] => Automatic validation enabled.
[var] => 1
)
[upload7] => Array
(
[path] => /home/devel/public_html/fx2/components/com_chronoforms6/chronoforms/uploads/
[estructura_organizacional] => Array
(
[extensions] => Array
(
[0] => jpg
[1] => png
[2] => gif
[3] => pdf
[4] => doc
[5] => docx
[6] => txt
[7] => zip
)
[info] => File is not present.
)
[var] => Array
(
)
)
)
Hi xoles,
Where does the "undefined" word come from in your code ?
Does this form use AJAX ?
Best regards,
Max
Where does the "undefined" word come from in your code ?
Does this form use AJAX ?
Best regards,
Max
I have also a field, but when i'm using the code below it's updating the field with and empty value.
if(empty($this->data("Fotovoorkant"))){
unset($this->data["Fotovoorkant"]);
}
Hi Jelle,
I understand that you could solve this later, correct ?
Best regards
I understand that you could solve this later, correct ?
$new_data = $this->data;
if(empty($this->data["Fotovoorkant"])){
unset($new_data["Fotovoorkant"]);
}
$this->set("new", $new_data);//use {var:new} as the data provider now
Best regards
This topic is locked and no more replies can be posted.
