I have the following code
I need to save the following to the database
Ploeg -> value needs to be JU13
Training -> choose date from dropdown
Welke speler -> choose player from dropdown
Aanwezig -> choose option from dropdown
A preview of this form is on -> http://bravoc.be/index.php?option=com_chronoforms5&chronoform=Aanwezigheid
I made a table in the database with following name lx59p_chronoengine_chronoforms_datatable_Aanwezigheid
and following fields
id uniq_id user_id created modified ploeg training naam opties
What do I need to do to make the save work?
<h2>Aanwezigheidslijst</h2><br>
Ploeg: <input type="text" name="ploeg" value="JU13" disabled><br><br>
<?php
$options = array();
$training[] = "<option value=''>--Training?--</option>";
$db =& JFactory::getDBO();
$query = "
SELECT `idt`, `ploegid`, `training`
FROM `#__training`
WHERE `ploegid`=24
ORDER BY `idt`;
";
$db->setQuery($query);
$data = $db->loadObjectList();
foreach ( $data as $d ) {
$training[] = "<option value='{$d->idt}'>{$d->training}</option>";
}
?>
<select class="" id="training" size="1" name="training">
<?php echo implode("\n", $training); ?>
</select>
<br>
<?php
$options = array();
$naam[] = "<option value=''>--Welke speler?--</option>";
$db =& JFactory::getDBO();
$query = "
SELECT `spelerid`, `ploegid`, `ploegid2`,`voornaam`, `achternaam`
FROM `#__spelers`
WHERE `ploegid`=24 OR `ploegid2`=24
ORDER BY `achternaam`;
";
$db->setQuery($query);
$data = $db->loadObjectList();
foreach ( $data as $d ) {
$naam[] = "<option value='{$d->spelerid}'>{$d->voornaam} {$d->achternaam}</option>";
}
?>
<select class="" id="naam" size="1" name="naam">
<?php echo implode("\n", $naam); ?>
</select>
<br>
<?php
$options = array();
$options[] = "<option value=''>--Aanwezig?--</option>";
$db =& JFactory::getDBO();
$query = "
SELECT `id`, `opties`
FROM `#__trainingsopties`
ORDER BY `opties`;
";
$db->setQuery($query);
$data = $db->loadObjectList();
foreach ( $data as $d ) {
$options[] = "<option value='{$d->id}'>{$d->opties}</option>";
}
?>
<select class="" id="opties" size="1" name="opties">
<?php echo implode("\n", $options); ?>
</select>
<input type="hidden" name="sendto" id="sendto"
value="<?php echo $databaseContact; ?>">
<br>
<div class="form-group gcore-form-row" id="form-row-2"><div class="gcore-input gcore-display-table" id="fin-fld1">
</div>
<div class="form-group gcore-form-row" id="form-row-22"><div class="gcore-input gcore-display-table" id="fin-button9"><input name="button9" id="button9" type="submit" value="Opslaan" class="form-control A" style="" data-load-state="" /></div></div>
I need to save the following to the database
Ploeg -> value needs to be JU13
Training -> choose date from dropdown
Welke speler -> choose player from dropdown
Aanwezig -> choose option from dropdown
A preview of this form is on -> http://bravoc.be/index.php?option=com_chronoforms5&chronoform=Aanwezigheid
I made a table in the database with following name lx59p_chronoengine_chronoforms_datatable_Aanwezigheid
and following fields
id uniq_id user_id created modified ploeg training naam opties
What do I need to do to make the save work?
Hi bert,
If your select names matches the table fields names then it should work, assuming you have a "db save" connected to the table.
Let us know if the problem persists!
Regards,
Max
If your select names matches the table fields names then it should work, assuming you have a "db save" connected to the table.
Let us know if the problem persists!
Regards,
Max
Problim still exist.
This is my code
This is my database table
If I fill the form on -> http://bravoc.be/index.php?option=com_chronoforms5&chronoform=Aanwezigheid in then it gives no error but if I check the table than there are no records in the table :-(
This is my code
<h2>Aanwezigheidslijst</h2>
<?php
$options = array();
$ploeg[] = "<option value=''>--Ploeg?--</option>";
$db =& JFactory::getDBO();
$query = "
SELECT `ploegid`, `ploegnaam`
FROM `#__ploegen`
WHERE `ploegid`=24
ORDER BY `ploegnaam`;
";
$db->setQuery($query);
$data = $db->loadObjectList();
foreach ( $data as $d ) {
$ploeg[] = "<option value='{$d->ploegid}'>{$d->ploegnaam}</option>";
}
?><br>
<select class="" id="ploeg" size="1" name="ploeg">
<?php echo implode("\n", $ploeg); ?>
</select>
<br>
<?php
$options = array();
$training[] = "<option value=''>--Training?--</option>";
$db =& JFactory::getDBO();
$query = "
SELECT `idt`, `ploegid`, `training`
FROM `#__training`
WHERE `ploegid`=24
ORDER BY `idt`;
";
$db->setQuery($query);
$data = $db->loadObjectList();
foreach ( $data as $d ) {
$training[] = "<option value='{$d->idt}'>{$d->training}</option>";
}
?>
<select class="" id="training" size="1" name="training">
<?php echo implode("\n", $training); ?>
</select>
<br>
<?php
$options = array();
$naam[] = "<option value=''>--Welke speler?--</option>";
$db =& JFactory::getDBO();
$query = "
SELECT `spelerid`, `ploegid`, `ploegid2`,`voornaam`, `achternaam`
FROM `#__spelers`
WHERE `ploegid`=24 OR `ploegid2`=24
ORDER BY `achternaam`;
";
$db->setQuery($query);
$data = $db->loadObjectList();
foreach ( $data as $d ) {
$naam[] = "<option value='{$d->spelerid}'>{$d->voornaam} {$d->achternaam}</option>";
}
?>
<select class="" id="naam" size="1" name="naam">
<?php echo implode("\n", $naam); ?>
</select>
<br>
<?php
$options = array();
$options[] = "<option value=''>--Aanwezig?--</option>";
$db =& JFactory::getDBO();
$query = "
SELECT `id`, `opties`
FROM `#__trainingsopties`
ORDER BY `opties`;
";
$db->setQuery($query);
$data = $db->loadObjectList();
foreach ( $data as $d ) {
$options[] = "<option value='{$d->id}'>{$d->opties}</option>";
}
?>
<select class="" id="opties" size="1" name="opties">
<?php echo implode("\n", $options); ?>
</select>
<input type="hidden" name="sendto" id="sendto"
value="<?php echo $databaseContact; ?>">
<br>
<div class="form-group gcore-form-row" id="form-row-2"><div class="gcore-input gcore-display-table" id="fin-fld1">
</div>
<div class="form-group gcore-form-row" id="form-row-22"><div class="gcore-input gcore-display-table" id="fin-button9"><input name="button9" id="button9" type="submit" value="Opslaan" class="form-control A" style="" data-load-state="" /></div></div>
This is my database table
Field Type Collation Attributes Null Default Extra Action
id int(11) No None AUTO_INCREMENT Browse distinct values Change Drop Primary Unique Index Fulltext
uniq_id varchar(50) utf8_general_ci No None Browse distinct values Change Drop Primary Unique Index Fulltext
user_id int(11) No None Browse distinct values Change Drop Primary Unique Index Fulltext
created datetime No 0000-00-00 00:00:00 Browse distinct values Change Drop Primary Unique Index Fulltext
modified datetime Yes NULL Browse distinct values Change Drop Primary Unique Index Fulltext
ploeg varchar(255) utf8_general_ci No None Browse distinct values Change Drop Primary Unique Index Fulltext
training varchar(255) utf8_general_ci No None Browse distinct values Change Drop Primary Unique Index Fulltext
naam varchar(255) utf8_general_ci No None Browse distinct values Change Drop Primary Unique Index Fulltext
opties varchar(255) utf8_general_ci No None Browse distinct values Change Drop Primary Unique Index Fulltext
If I fill the form on -> http://bravoc.be/index.php?option=com_chronoforms5&chronoform=Aanwezigheid in then it gives no error but if I check the table than there are no records in the table :-(
Hi bertvdb,
I don't' see anything wrong in your code.
Please drag a Debugger action into the On Submit event, then submit the form and post the debug results here.
Note: if you are using the Easy Wizard you can turn on Debug on the Others tab in CFv4 or the Setup tab in CFv5.
Bob
I don't' see anything wrong in your code.
Please drag a Debugger action into the On Submit event, then submit the form and post the debug results here.
Note: if you are using the Easy Wizard you can turn on Debug on the Others tab in CFv4 or the Setup tab in CFv5.
Bob
Data Array
Array
(
[option] => com_chronoforms5
[chronoform] => Aanwezigheid
[event] => submit
[ploeg] => 24
[training] => 1
[naam] => 140
[opties] => 1
[sendto] =>
[button9] => Opslaan
[id] => 0
)
Array
(
)
Errors
Array
(
)
Debug Info
Array
(
[11] => Array
(
[DB Save] => Array
(
[Queries] => Array
(
)
)
)
)
Hi bertvdb,
The problem may be that id=0 at the end of the data array. Do you know where that is coming from?
My guess is that the DB Save is failing because of that. Otherwise it may just not be linked to the table.
Bob
The problem may be that id=0 at the end of the data array. Do you know where that is coming from?
My guess is that the DB Save is failing because of that. Otherwise it may just not be linked to the table.
Bob
Don't know but when i change the DB save settings to
Enabled -> Yes
Table name -> lx59p_chronoengine_chronoforms_datatable_Aanwezigheid
Save under Model iD -> Yes
Multi save -> No
Model ID -> Data then I get this code
And I get this in my table
Volledige teksten id uniq_id user_id created modified ploeg training naam opties
2 0 2014-09-12 16:20:57 NULL
But no values in ploeg - training - naam and opties
Enabled -> Yes
Table name -> lx59p_chronoengine_chronoforms_datatable_Aanwezigheid
Save under Model iD -> Yes
Multi save -> No
Model ID -> Data then I get this code
Data Array
Array
(
[option] => com_chronoforms5
[chronoform] => Aanwezigheid
[event] => submit
[ploeg] => 24
[training] => 1
[naam] => 140
[opties] => 1
[sendto] =>
[button9] => Opslaan
[Data] => 2
)
Array
(
)
Errors
Array
(
)
Debug Info
Array
(
[11] => Array
(
[DB Save] => Array
(
[Queries] => Array
(
[0] => INSERT INTO `lx59p_chronoengine_chronoforms_datatable_Aanwezigheid` (`user_id`, `created`) values ('0', '2014-09-12 16:20:57');
)
)
)
)
And I get this in my table
Volledige teksten id uniq_id user_id created modified ploeg training naam opties
2 0 2014-09-12 16:20:57 NULL
But no values in ploeg - training - naam and opties
Ok, as Bob suggested, its the id, please set "save under model id" to "no", and use this code in a "custom code" action ABOVE the "db save":
<?php
unset($form->data["id"]);
This topic is locked and no more replies can be posted.