Forums

pass db id to url link in CC5

Twincarb 11 Mar, 2017
Hi Max & Bob,

I am wanting to pass the id paramater of a record to a url in order to have a link which will open an edit form in a modal window. I am struggling to pass the id paramater into the html code. The lines below are what I have tried.

<?php
$id = ['job_view']['id'];
?>
<a href="/jobs/new-job-data?cont=lists&ccname=JobView&act=edit&gcb=<?php echo $id; ?>" >


I have also tried doing it with {job_view.id} as well directly in the html but that also doesn't parse.

Any hints on where I am going wrong?

The bigger picture on the project is a single form which is used to populate the db I then use CC to display the record, depending there are 4 areas on the CC view that are editable, depending on who is logged on it depends on what they can edit.
This means there are an additional 4 edit forms which depending on which edit link is visable depends on the edit form they are presented with. This means they only edit the data that they can see.

I can almost see the light at the end of the project....

Regards,

Dave
GreyHead 11 Mar, 2017
Hi Dave,.

Is this displayed in a CC row? If so then <?php echo $row['job_view']['id']; ?> should do what you need.

Bob
Twincarb 11 Mar, 2017
Hi Bob,

It's not in the table, it is in the "actions" - "view" I thought I would be able to call one of the other "views" that I have there to link to the appropriate form that I want to display.

All that is getting parsed is /jobs/new-job-data?cont=lists&ccname=JobView&act=edit&gcb=
which is missing the id at the end for the record to be loaded.

Dave
Twincarb 11 Mar, 2017
1 Likes
Hi Bob,

I got my head fixated on this one.... took a step back and just used {job_view.id} considering I am using similar expressions throughout I am not sure why I didn't do it first time!

Regards,
Dave
Twincarb 12 Mar, 2017
I have moved onto the next step and the new form opens in the modal window, I have set up the db read action where to select the record from url I am using the following code.


<?php
return array("id_job"=> $form->data["gcb"]);
?>


This is now selecting the data for the entry that I am wanting as shown in the debug information below. What I am not managing to do is populate any of the fields on the form apart from an extra box I called gcb which is showing the record number, all of the Form Field boxes are named as per the db columns, I have tried with Modal enabled in the DB Read using Data[id_job] as well as us model no id_job


Array
(
    [cont] => lists
    [ccname] => JobView
    [act] => r1edit
    [gcb] => 8
    [tmpl] => component
    [Data] => Array
        (
            [0] => Array
                (
                    [id_job] => 8
                    [r1_col_time] => 20:14
                    [r1_del_time] => 21:55
                    [r1_miles] => 
                    [r1_comments] => 
                )

        )

)


Many thanks in advance as normal I suspect I am overlooking something simple!
Twincarb 12 Mar, 2017
I have made a bit of sense of it now and progressed🙂

to input the data into the form inputs I had to reference both of the Arrays shown above ie Data.0[id_job] which when used on each cell fills them with the data.

The next issue was how to save to the database, to see what was happening I put a debugger on the on save this produced


Array
(
    [cont] => lists
    [ccname] => JobView
    [act] => r1edit
    [gcb] => 8
    [tmpl] => component
    [chronoform] => R1Form
    [event] => submit
    [Data_0] => Array
        (
            [id_job] => 8
            [r1_col_time] => 20:14
            [r1_del_time] => 21:55
            [r1_miles] => 500
            [r1_comments] => This is a new comment
        )

    [button117] => Submit
)



looking at the above, I can see that the data is in an array called Data_0 so in the save to database I needed to tell it to use a model and set the name to Data_0.

clicking save on the form now submits the data to the database and updates the cells in that record.🙂

Now I just need to adjust all of the other forms that I have🙂
This topic is locked and no more replies can be posted.

VPS & Email Hosting 20% discount

{item:title} {images:#}