Forums

DB Read -> modify one column in 1 record -> DB Save

GESign 04 Nov, 2016
Good Evening,

I had tried 2 days, but I can't do this:
I would like to get a record from a table and after I would like to change a column (status) in the record and I would like to save the change. I setted DB Read to Multi read = No because I am looking for 1 exact record based on ID. I also would like to know how it works with state ON.

I can read the record and all of the columns I need. Debugger Data Array info:
Array
(
    [option] => com_chronoforms5
    [chronoform] => Test
    [id] => 27
    [uniq_id] => ab044ac614e4bcfd571091cf3b338b1b5c7b13b7
    [user_id] => 241
    [status] => Start
    [change_status] => Array
        (
            [id] => 0
        )

)


I want to manipulate the status. I tried like this (I have made a hidden input for this in Designer area: <input type="hidden" name="status1" id="status1" value="" />) and I created a Custom Code in Setup area:
$status1 = 'In Progress';


I wanted to update the cell (column) with DB Save like this (Model ID is ON and = change_status):
<?php
return array( 'change_status.id' => '27', 'change_status.status' => $status1 );
?>

or like this:
$form->data['status'] = $status1;

I used the ID to let the system know this record must to be updated.

What did I make wrong? Sorry for my data array handling is very poor.
GESign 09 Nov, 2016
1 Likes
I found the following solution:

Into Custom Code:
$form->data['change_status']['status'] = 'In Progress';
I also needed to use foreach cycle to read other datas from my table but this is an other story.

Into DB Save:
    <?php
    return array( 'change_status.id' => '27');
    ?>
This part is not for writing but only for select!
This topic is locked and no more replies can be posted.