Can Chronoforms be user to build "mini-apps"?
I got by my delete issue by pulling it out of OnSubmit and moving things to the form HTML as below...
So only one problem left...
created the form tried to use the CF admin to create the table while setting the 'EmployeeName' field to a PK... failed db creation with an "auto_increment" error (odd as I know there was no check mark there) use the CF admin to create the table without a 'manual' PK verified the form could save to the db (insert 'my record') used MySQL Browser to edit the table and set the 'EmployeeName' field to a PK detached/reattached the table to the form in the CF Admin (to sense the db change) verified the form could update 'my record' in the db deleted the sole record using MySQL Browser so I could test my form switching between loading defaults (no record to load) and loading the users record to 'edit' submitted new form and found that my record was not added opened MySQL Browser to remove PK, detached/reattached db in CF Admin, and retest saved the record [/list:o]
Inserts and Updates should both work at the same time with the PK set on one of my fields right? What might I have done incorrectly?
<?php
global $user;
$user = &JFactory::getUser();
$database = &JFactory::getDBO();
if ($_REQUEST["delete"]){
$database->setQuery( "DELETE From #__chronoforms_carpooldrivers WHERE EmployeeName='$user->name'" );
if (!$result = $database->loadObject()) {
header( 'Location: http://intranet/index.php?option=com_chronocontact&chronoformname=CarPoolDrivers' ) ;
}
}
$database->setQuery( "SELECT
...
...
<input type="submit" value="Submit Form">
<input type="reset" value="Reset Form">
<input type=button value="Delete My Record" onClick="if (confirm('Delete <?php echo $user->name?>?')) window.location='index.php?option=com_chronocontact&chronoformname=CarPoolDrivers&delete=1';">
So only one problem left...
Problem 2
I also seem to have a problem using the "PRIMARY KEY" trick to have the form update the database; problem being that it kills the inserts of new records. Here is how I implemented it...
[list=1]
Inserts and Updates should both work at the same time with the PK set on one of my fields right? What might I have done incorrectly?
I have no custom SQL for this, Chronoforms should be inserting data as it always does, the "trick" (that I interpreted from another post) was just to make one of the form fields a PK in the db, and that this would make CF switch between insert and update on the fly.
When I do this as explained, the update works great on already existing data, but the insert breaks for new records.
When I do this as explained, the update works great on already existing data, but the insert breaks for new records.
Auto generated code is...
...and if important... the dbclasses field in chronocontact contains...
... i think the parent::__construct line somehow relates to the PK set on the table.
<?php
if($paramsvalues->dbconnection == "Yes"){
$user = JFactory::getUser();
$row =& JTable::getInstance("chronoforms_carpooldrivers", "Table");
srand((double)microtime()*10000);
$inum = "I" . substr(base64_encode(md5(rand())), 0, 16);
JRequest::setVar( "recordtime", JRequest::getVar( "recordtime", date("Y-m-d")." - ".date("H:i:s"), "post", "string", "" ));
JRequest::setVar( "ipaddress", JRequest::getVar( "ipaddress", $_SERVER["REMOTE_ADDR"], "post", "string", "" ));
JRequest::setVar( "uid", JRequest::getVar( "uid", $inum, "post", "string", "" ));
JRequest::setVar( "cf_user_id", JRequest::getVar( "cf_user_id", $user->id, "post", "int", "" ));
$post = JRequest::get( "post" , JREQUEST_ALLOWRAW );
if (!$row->bind( $post )) {
JError::raiseWarning(100, $row->getError());
}
if (!$row->store()) {
JError::raiseWarning(100, $row->getError());
}
global $row_jos_chronoforms_carpooldrivers;
$row_jos_chronoforms_carpooldrivers = $row;
}
?>
...and if important... the dbclasses field in chronocontact contains...
<?php
if (!class_exists('Tablechronoforms_carpooldrivers')) {
class Tablechronoforms_carpooldrivers extends JTable {
var $cf_id = null;
var $uid = null;
var $recordtime = null;
var $ipaddress = null;
var $cf_user_id = null;
var $subject = null;
var $UserEmail = null;
var $RequestDate = null;
var $EmployeeName = null;
var $Contact = null;
var $StartDate = null;
var $WorkDays = null;
var $WorkHours = null;
var $ContactType = null;
var $Ward = null;
var $PickupWard1 = null;
var $PickupWard2 = null;
var $PickupWard3 = null;
var $PickupWard4 = null;
function __construct( &$database ) {
parent::__construct( 'jos_chronoforms_carpooldrivers', 'EmployeeName', $database );
}
}
}
?>
... i think the parent::__construct line somehow relates to the PK set on the table.
Hmmm, i rocked the table back to where EmployeeName was no longer a PK, and the dbclasses field in the chronocontact table updated to the following...
If my idea is correct that parent::construct is important.... funny how the insert works perfectly when 'cf_id' is in the 'equation' (the default PK and auto incrementing field), but fails when 'cf_id' is omitted leaving only 'EmployeeName' when I manually updated the table to add a second PK.
<?php
if (!class_exists('Tablechronoforms_carpooldrivers')) {
class Tablechronoforms_carpooldrivers extends JTable {
var $cf_id = null;
var $uid = null;
var $recordtime = null;
var $ipaddress = null;
var $cf_user_id = null;
var $subject = null;
var $UserEmail = null;
var $RequestDate = null;
var $EmployeeName = null;
var $Contact = null;
var $StartDate = null;
var $WorkDays = null;
var $WorkHours = null;
var $ContactType = null;
var $Ward = null;
var $PickupWard1 = null;
var $PickupWard2 = null;
var $PickupWard3 = null;
var $PickupWard4 = null;
function __construct( &$database ) {
parent::__construct( 'jos_chronoforms_carpooldrivers', 'cf_id', $database );
}
}
}
?>
If my idea is correct that parent::construct is important.... funny how the insert works perfectly when 'cf_id' is in the 'equation' (the default PK and auto incrementing field), but fails when 'cf_id' is omitted leaving only 'EmployeeName' when I manually updated the table to add a second PK.
Ok, I will cut this and move to bugs, I agree with you this needs to be fixed!
Max
Max
Good news Max!
Out of curiosity, when might a build containing the fix be released? Not looking for a hard date, just wondering if I should deploy my form with some workarounds that I have found, or if I should sit tight and wait for the update and make the form "properly" from the start.
Out of curiosity, when might a build containing the fix be released? Not looking for a hard date, just wondering if I should deploy my form with some workarounds that I have found, or if I should sit tight and wait for the update and make the form "properly" from the start.
Hi danieli,
I can't tell a date, all I can say is that I'm working on it, many features need to be added to the next release, give me may be 2 weeks at least!
Regards
Max
I can't tell a date, all I can say is that I'm working on it, many features need to be added to the next release, give me may be 2 weeks at least!
Regards
Max
This topic is locked and no more replies can be posted.