cheesegrits
Support Gopher
Rob,
I think I've identified where people are having issues with the "job application" tutorial, and other new form / table weirdness in general.
In the tutorial, it tells you to create and save the form, then immediately go to the Tables page and "Update Database":
The problem being, if you do this, Fabrik gets its panties in a wad because of the logic in the updatefabrikTable() function:
As far as I can tell, the problem is because the table view hasn't been created yet, there is no $oForm->table_id ... so the $oTable object doesn't get created. So when it tests for !$oTable->databaseTableExists() ... weirdness ensues. I think the extent of the weirdness depends on how you have PHP set to handle errors.
I suspect the fix is to a) move that databaseTableExists test inside the "if ( $oForm->table_id > 0 )" block, and b) reword the tutorial appropriately, so it explains that when you save the Form (with "Record to database" selected) it will automagically create the table at that point, and the first thing you should then do is "Create Table View" (NOT "Update table").
-- hugh
I think I've identified where people are having issues with the "job application" tutorial, and other new form / table weirdness in general.
In the tutorial, it tells you to create and save the form, then immediately go to the Tables page and "Update Database":
Create the Form:
[blah blah]
3. Fill in the form with the following information:
[blah]
4. Select "Record Form Results Database".
[blah]
6. Press "Save". This will return you to the list of "Currently Available Forms".
Create the Fabrik Table:
[blah]
Click the "Update Database" link at the extreme right of the "job types" row on the Fabrik form page. This will create a database table called "fabrik_formdata_x" where "x" is the form's id. You will then receive an "Update Successful" confirmation message.
Click on the "Create Table View" link to create a Fabrik table view of the database table.
The problem being, if you do this, Fabrik gets its panties in a wad because of the logic in the updatefabrikTable() function:
Code:
function updatefabrikDatabase( $formId ) {
global $database, $mosConfig_dbprefix;
$oForm = new fabrikForm( $database );
$oForm->load( $formId );
//use this in case there is not table view linked to the form
$databaseTableName = $mosConfig_dbprefix."fabrik_formdata_".$formId;
$thisDb = $database;
if ( $oForm->table_id > 0 ) {
//there is a table view linked to the form so lets load it
$oTable = new fabrikTable( $database );
$oTable->load( $oForm->table_id );
$oConn = $oTable->getConnection( );
$databaseTableName = $oTable->db_table_name;
$thisDb = $oTable->_oConnDB;
}
if ( !$oTable->databaseTableExists( ) ) {
$oTable->createFormTable( $oForm );
} else {
$oTable->ammendTable( $oForm );
}
}
As far as I can tell, the problem is because the table view hasn't been created yet, there is no $oForm->table_id ... so the $oTable object doesn't get created. So when it tests for !$oTable->databaseTableExists() ... weirdness ensues. I think the extent of the weirdness depends on how you have PHP set to handle errors.
I suspect the fix is to a) move that databaseTableExists test inside the "if ( $oForm->table_id > 0 )" block, and b) reword the tutorial appropriately, so it explains that when you save the Form (with "Record to database" selected) it will automagically create the table at that point, and the first thing you should then do is "Create Table View" (NOT "Update table").
-- hugh