I have an issue with passing data from CF5 to a where clause in CC5.
I've read the related FAQ and I just can't nail it. The basic scenario is:
* CF5 form with model 'constants' and a drop down constants[host]
* Calls the index action on a CC5 connection with model constants
All works fine without any conditions and the entire table is returned. Similarly, if I hard code a where condition I can filter the results.
However I want to use constants[host] passed from the form, so I do:
Nothing is displayed. I've tried about 15 different formatting approaches just in case.
If I throw in a showstopper to prevent the call to CC5 and echo $form->data['constants']['host']) it displays as expected e.g. host.domain.com. However output from the CC5 debugger shows that the condition being executed is "WHERE `constants`.`host` IS NULL". So basically the the form data isn't being passed over.
I'm stumped. Can anyone shed some light on this?
Regards
John
I've read the related FAQ and I just can't nail it. The basic scenario is:
* CF5 form with model 'constants' and a drop down constants[host]
* Calls the index action on a CC5 connection with model constants
All works fine without any conditions and the entire table is returned. Similarly, if I hard code a where condition I can filter the results.
However I want to use constants[host] passed from the form, so I do:
return array('constants.host'=> $form->data['constants']['host']);
Nothing is displayed. I've tried about 15 different formatting approaches just in case.
If I throw in a showstopper to prevent the call to CC5 and echo $form->data['constants']['host']) it displays as expected e.g. host.domain.com. However output from the CC5 debugger shows that the condition being executed is "WHERE `constants`.`host` IS NULL". So basically the the form data isn't being passed over.
I'm stumped. Can anyone shed some light on this?
Regards
John
Hi John,
Please try
You said in another post that you have php 5.5.9, please test v6 with that, it "may" work.
Best regards,
Max
Please try
$this->data
instead.
You said in another post that you have php 5.5.9, please test v6 with that, it "may" work.
Best regards,
Max
Hi Max,
Yep that works. In fact I had already tried this but I've just discovered it only works if the host name doesn't have a dash (-) in it. When I tested this syntax last might I must have selected the host that did. Of course PHP doesn't like dashes in variable names, so I can see why this is happening. I've tried to escape the dash with \ but it still doesn't work.
The host with the dash is only a dev server and I could rename it but it's a bit of work. Is there a way you can think of to escape it?
Thanks for the prompt response on this. I'll run up CC6 with 5.5.9 and let you know how it goes.
Cheers
John
Please try
$this->data
Yep that works. In fact I had already tried this but I've just discovered it only works if the host name doesn't have a dash (-) in it. When I tested this syntax last might I must have selected the host that did. Of course PHP doesn't like dashes in variable names, so I can see why this is happening. I've tried to escape the dash with \ but it still doesn't work.
The host with the dash is only a dev server and I could rename it but it's a bit of work. Is there a way you can think of to escape it?
Thanks for the prompt response on this. I'll run up CC6 with 5.5.9 and let you know how it goes.
Cheers
John
Hi Max,
I installed CC6 on PHP5.5.9 and no errors so far. I tried to restore a backup of a CC5 connection and got "Invalid backup file extension.".
Is there a way to migrate from CC5 to CC6?
Regards
John
I installed CC6 on PHP5.5.9 and no errors so far. I tried to restore a backup of a CC5 connection and got "Invalid backup file extension.".
Is there a way to migrate from CC5 to CC6?
Regards
John
Well I was wrong about 2 things.
The first is that while using $this->data works when loading the CC5 connection from the form initially, when the form returns to the connection afer an edit the host string is empty again. In the end I gave up and wrote the values to session before calling CC then retrieved them for the conditional statement in CC5. In case it is of use to someone in the future, this is the working code that sets the conditional statement for CC5:
The second thing I was wrong about was not getting the host with the dash in the name. It was a typo in the form.
Cheers
John
The first is that while using $this->data works when loading the CC5 connection from the form initially, when the form returns to the connection afer an edit the host string is empty again. In the end I gave up and wrote the values to session before calling CC then retrieved them for the conditional statement in CC5. In case it is of use to someone in the future, this is the working code that sets the conditional statement for CC5:
$host_scope = $_SESSION['constants']['host'];
$type = $_SESSION['constants']['type'];
if($host_scope == "all" && $type == "all"){
return array('constants.host !=' => "NULL");
} elseif($host_scope == "all" && $type != "all"{
return array('constants.host !=' => "NULL", 'constants.type' => $type);
} elseif($host_scope != "all" && $type == "all"{
return array('constants.host' => $host_scope, 'constants.type !=' => $type);
} else {
return array('constants.host'=> $host_scope, 'constants.type' => $type);
}
The second thing I was wrong about was not getting the host with the dash in the name. It was a typo in the form.
Cheers
John
Hi John,
Great!
No, unfortunately there is no migration from v5 to v6.
Best regards,
Max
Great!
No, unfortunately there is no migration from v5 to v6.
Best regards,
Max
This topic is locked and no more replies can be posted.