A couple of things that I noticed. For one - to get the chckbox checked when returning to the form, you need to have the code in place that will display the original results. And second, when returning to the form, you are using another insert to input the data, and not an update to change existing data. Dolphin does have a way to use the same form for update and insert, but you still have to specify which one you would use. It is a lengthy explanation (at least for me it is) so I will do my best to explain.
I tend to do things the long way, so heres what I did. Create 2 different forms - One for Insert and one for update. Like so:
Insert ---
$aForm = array(
'form_attrs' => array(
'name' => 'form_my',
'method' => 'post',
),
'params' => array (
'db' => array(
'table' => 'module_table', // table name
'key' => 'module_table_id', // key field name
'uri' => 'module_table_uri_field', // uri field name
'uri_title' => '', // title field to generate uri from
'submit_name' => 'submit_form',
),
'csrf' => array(
'disable' => true,
)
),
'inputs' => array(
'header1' => array(
'type' => 'block_header',
'caption' => _t('_language key'),
),
'checkbox_field' => array(
'type' => 'checkbox',
'name' => 'checkbox_field',
'value' => $checkbox_field,
'caption' => _t('_language key'),
'required' => true,
'checker' => array (
'func' => 'avail',
'error' => _t('_language key'),
),
// database params
'db' => array (
'pass' => 'Xss',
),
),
'header1_end' => array(
'type' => 'block_end'
),
'submit' => array(
'type' => 'submit',
'name' => 'submit_form',
'value' => _t('_Submit')
)
),
);
$oForm = new BxTemplFormView ($aForm);
$oForm->initChecker();
if ($oForm->isSubmittedAndValid()) {
$aValsAdd = array (
);
if ($oForm->insert($aValsAdd )) {
$sActionKey = '_success';
} else {
$sActionKey = '__fail';
}
$sActionText = MsgBox(_t($sActionKey), 3);
} else {
echo $oForm->getCode();
}
and one for update:
$pSomething = mysql_query("SELECT * FROM `table` WHERE `table_field` = '$some variable'");
while ($row = mysql_fetch_array($pSomething)) {
$checkbox_field = $row["checkbox_field"];
}
$aForm = array(
'form_attrs' => array(
'name' => 'form_my',
'method' => 'post',
),
'params' => array (
'db' => array(
'table' => 'module_table', // table name
'key' => 'module_table_id', // key field name
'uri' => 'module_table_uri_field', // uri field name
'uri_title' => '', // title field to generate uri from
'submit_name' => 'submit_form',
),
'csrf' => array(
'disable' => true,
)
),
'inputs' => array(
'header1' => array(
'type' => 'block_header',
'caption' => _t('_cf_memberships_aim_header', $Name, $Description, $Price, $Unit),
),
'checkbox_field' => array(
'type' => 'checkbox',
'name' => 'checkbox_field',
'value' => $checkbox_field,
'caption' => _t('_language key'),
'required' => true,
'checker' => array (
'func' => 'avail',
'error' => _t('_language key'),
),
// database params
'db' => array (
'pass' => 'Xss',
),
),
'header1_end' => array(
'type' => 'block_end'
),
'submit' => array(
'type' => 'submit',
'name' => 'submit_form',
'value' => _t('_Submit')
)
),
);
$oForm = new BxTemplFormView ($aForm);
$oForm->initChecker();
if ($oForm->isSubmittedAndValid()) {
$aValsAdd = array (
);
if ($oForm->update ($module_table_id, $aValsAdd )) {
$sActionKey = '_success';
} else {
$sActionKey = '_fail';
}
$sActionText = MsgBox(_t($sActionKey), 3);
} else {
echo $oForm->getCode();
}
I know there is a way to only have the one form and then just calling the form when needed, but not knowing exactly where you are putting this code, I can't tell you exactly where to put the form. If you want more details, PM me.