I am trying to save to a table with the following custom code on On Submit which should work.
//$record is an array with matching parameters to a structure of a table
$row =& JTable::getInstance('tvs5y_custom_app1_employment_history', 'Table');
$row->bind($record);
$row->store();
However it does not save but prints this error message:-
Table tvs5y_custom_app1_employment_history not supported. File not found.
However if I use DBSave I can load this table without any problem.
Do you have to set something up beforehand to tell where JTable to look? I thought it was able to get any table from the default database. What I don't understand if I can get this table with DBSave why not JTable as well?
//$record is an array with matching parameters to a structure of a table
$row =& JTable::getInstance('tvs5y_custom_app1_employment_history', 'Table');
$row->bind($record);
$row->store();
However it does not save but prints this error message:-
Table tvs5y_custom_app1_employment_history not supported. File not found.
However if I use DBSave I can load this table without any problem.
Do you have to set something up beforehand to tell where JTable to look? I thought it was able to get any table from the default database. What I don't understand if I can get this table with DBSave why not JTable as well?
Hi peterswa62,
If you look at lines 42-64 of /administrator/components/com_chronoforms/form_actions/db_save/db_save.php you will see that the ChronoForms DB Save action dynamically creates a PHP class to match the selected table. You'll need to add this, or a static class to use the Joomla! JTable code.
Bob
If you look at lines 42-64 of /administrator/components/com_chronoforms/form_actions/db_save/db_save.php you will see that the ChronoForms DB Save action dynamically creates a PHP class to match the selected table. You'll need to add this, or a static class to use the Joomla! JTable code.
Bob
Thanks. Cannot get access to this code as its in a restricted folder. Could you show me the code here?
Hi peterswa62,
If you download a copy of ChronoForms here and unzip it you can see any of the files.
Bob
If you download a copy of ChronoForms here and unzip it you can see any of the files.
Bob
You mean you need something like this:-
<?php
defined('_JEXEC') or die();
class TableRecipes extends JTable
{
var $id = null;
var $ingredients = null;
var $instructions = null;
var $serves = null;
var $difficulty = null;
var $prep_time = null;
var $cook_time = null;
var $published = 0;
function __construct(&$db)
{
parent::__construct( '#__recipes', 'id', $db );
}
}
If so wouldn't you have to put this in a file and include it in a link with any code you use? Where is it best to keep such files?
<?php
defined('_JEXEC') or die();
class TableRecipes extends JTable
{
var $id = null;
var $ingredients = null;
var $instructions = null;
var $serves = null;
var $difficulty = null;
var $prep_time = null;
var $cook_time = null;
var $published = 0;
function __construct(&$db)
{
parent::__construct( '#__recipes', 'id', $db );
}
}
If so wouldn't you have to put this in a file and include it in a link with any code you use? Where is it best to keep such files?
Hi peterswa62 ,
Yes, that's it.
Either you generate it dynamically as ChronoForms does; or add it in a Custom Code action in your form where you need it; or, if you need it in multiple forms or events; then put it in a convenient file and include it from a Custom Code action when you need it. I tent to use the folder /components/com_chronoforms/extras/ and include as needed.
Bob
Yes, that's it.
Either you generate it dynamically as ChronoForms does; or add it in a Custom Code action in your form where you need it; or, if you need it in multiple forms or events; then put it in a convenient file and include it from a Custom Code action when you need it. I tent to use the folder /components/com_chronoforms/extras/ and include as needed.
Bob
This topic is locked and no more replies can be posted.