Hi all!
Can I test when a Custom Code runs and what values that comes out of My SQL-query?
I am not sure what is wrong in my code and need to debug it further than the Debug action in CFv4
//JeLu
Can I test when a Custom Code runs and what values that comes out of My SQL-query?
I am not sure what is wrong in my code and need to debug it further than the Debug action in CFv4
//JeLu
Hello JeLu,
I'm not a Chrono professional, but after checking your new post, I think that the following links may help:
What is the Custom Code action?
P.S: I'm just an automated service😉
I'm not a Chrono professional, but after checking your new post, I think that the following links may help:
What is the Custom Code action?
P.S: I'm just an automated service😉
Hi Jelu,
I use code like
The first version shows a system message on the next page load, the second just dumps a <div> into the current output.
Bob
I use code like
$app =& JFactory::getApplication();
$app->enqueuemessage('$var: '.print_r($var, true).'<hr />');
orecho'<div>$var: '.print_r($var, true).'</div>';
to add debug code almost anywhere.
The first version shows a system message on the next page load, the second just dumps a <div> into the current output.
Bob
Thank You!
I get the info I want from my DB. Now I wonder if I can use that value in default value. I tried
But it only shows $data and then I wonder if it is not possible to do it like this?
//JeLu
I get the info I want from my DB. Now I wonder if I can use that value in default value. I tried
<?php echo '$data'; ?>
But it only shows $data and then I wonder if it is not possible to do it like this?
//JeLu
Hi JeLu,
ChronoForms puts data into the $form->data array as far as I know $data will be empty unless you have specifically set a value.
Bob
ChronoForms puts data into the $form->data array as far as I know $data will be empty unless you have specifically set a value.
Bob
Hi!
I have this code in a Custom Code-action:
[code][/<?php
$user =& JFactory::getUser();
$db =& JFactory::getDBO();
$query = "
SELECT `cf_id`, `cf_user_id`, `foo
FROM `#__chronoforms_data`
WHERE `cf_user_id` = '{$user->id}' ORDER BY `cf_id` DESC LIMIT 1
";
$db->setQuery($query);
$data = $db->loadArray();
$form->data = array_merge($form->data, $data);
$app =& JFactory::getApplication();
$app->enqueuemessage('$data: '.print_r($data, true).'<hr />');
?>code]
Now when the check runs, $data is empty.
In Default Field Value I have put this:
I think that SQL-query is correct but it is not merged with $form->data?!
I have this Custom Code in an Authenticator-action->Allowed. In Allowed there is first a Multi-Page action second a Custom Code action and finally a Show HTML action. I have tested the Custom Code- action to run in On Load event too but that did not help.
I have my Custom Code in View mode. If I set it in Controller Mode the Array in Debug becomes empty at that page.
//JeLu
I have this code in a Custom Code-action:
[code][/<?php
$user =& JFactory::getUser();
$db =& JFactory::getDBO();
$query = "
SELECT `cf_id`, `cf_user_id`, `foo
FROM `#__chronoforms_data`
WHERE `cf_user_id` = '{$user->id}' ORDER BY `cf_id` DESC LIMIT 1
";
$db->setQuery($query);
$data = $db->loadArray();
$form->data = array_merge($form->data, $data);
$app =& JFactory::getApplication();
$app->enqueuemessage('$data: '.print_r($data, true).'<hr />');
?>code]
Now when the check runs, $data is empty.
In Default Field Value I have put this:
<?php '.print_r($form->data->foo, true).'; ?>
I think that SQL-query is correct but it is not merged with $form->data?!
I have this Custom Code in an Authenticator-action->Allowed. In Allowed there is first a Multi-Page action second a Custom Code action and finally a Show HTML action. I have tested the Custom Code- action to run in On Load event too but that did not help.
I have my Custom Code in View mode. If I set it in Controller Mode the Array in Debug becomes empty at that page.
//JeLu
Hi JeLu,
Is $db->loadArray() a valid Joomla! Database method? I'm not sure that it is.
Bob
Is $db->loadArray() a valid Joomla! Database method? I'm not sure that it is.
Bob
This topic is locked and no more replies can be posted.