Hey fiolks, I am stuck again and wondering if anyone can help me out.
A while back I made a module for a mental health site (using the groups module as the base). This was on a 7.1 version. I have installed 7.3.2 and am in the process of recreating the module. I am making a few changes based upon actual usage needs and a few other reasons.
Here is my dilemma:
First off, using a normal form layout on the BxGroupsModule page - the form is not being submitted. Here is what I have:
function actionTriageAddGeneralHealth ()
{
$client = $_GET['client'];
// Demographics Section
$aForm = array(
'form_attrs' => array(
'name' => 'form_general_health',
'method' => 'post',
),
'params' => array (
'db' => array(
'table' => 'cf_clients_general_health', // table name
'key' => 'general_health_id', // key field name
'uri' => '', // uri field name
'uri_title' => '', // title field to generate uri from
'submit_name' => 'submit_general_health_form',
),
'csrf' => array(
'disable' => true,
)
),
'inputs' => array(
'header1' => array(
'type' => 'block_header',
),
'HeightFeet' => array(
'type' => 'select',
'name' => 'HeightFeet',
'value' => $HeightFeet,
'values' => array(
'' => '',
2 => 2,
3 => 3,
4 => 4,
5 => 5,
6 => 6,
7 => 7,
),
'attrs' => array(
'id' => 'HeightFeet',
'onblur' => '',
),
'required' => true,
// checker params
'checker' => array (
'func' => 'length',
'params' => array(1,1),
'error' => _t('_cf_clients_height_feet_err'),
),
'caption' => _t("_cf_clients_height_feet"),
'db' => array (
'pass' => 'Xss',
),
),
'HeightInches' => array(
'type' => 'select',
'name' => 'HeightInches',
'value' => $HeightInches,
'attrs' => array(
'id' => 'HeightInches',
),
'values' => array(
'' => '',
0 => 0,
1 => 1,
2 => 2,
3 => 3,
4 => 4,
5 => 5,
6 => 6,
7 => 7,
8 => 8,
9 => 9,
10 => 10,
11 => 11,
),
'required' => true,
// checker params
'checker' => array (
'func' => 'length',
'params' => array(1,2),
'error' => _t('_cf_clients_height_inches_err'),
),
'caption' => _t("_cf_clients_height_inches"),
'db' => array (
'pass' => 'Xss', // do XSS clear before getting this value, see BxDolFormCheckerHelper class for all pass* functions
),
),
'Weight' => array(
'type' => 'text',
'name' => 'Weight',
'attrs' => array(
'id' => 'Weight',
),
'required' => true,
// checker params
'checker' => array (
'func' => 'length',
'params' => array(1,4),
'error' => _t('_cf_clients_weight_err'),
),
'caption' => _t("_cf_clients_weight"),
'db' => array (
'pass' => 'Xss', // do XSS clear before getting this value, see BxDolFormCheckerHelper class for all pass* functions
),
),
'BMI' => array(
'type' => 'text',
'name' => 'BMI',
'attrs' => array(
'id' => 'BMI',
'readonly' => true,
),
'caption' => _t("_cf_clients_bmi"),
'db' => array (
'pass' => 'Xss', // do XSS clear before getting this value, see BxDolFormCheckerHelper class for all pass* functions
),
),
'WeightOpinion' => array(
'type' => 'select',
'name' => 'WeightOpinion',
'caption' => _t("_cf_clients_weight_opinion"),
'values' => array(
'' => '',
'Too High' => 'Too High',
'Too Low' => 'Too Low',
'About Right' => 'About Right',
),
'value' => $WeightOpinion,
'required' => true,
// checker params
'checker' => array (
'func' => 'length',
'params' => array(1,25),
'error' => _t('_cf_clients_weight_opinion_err'),
),
'db' => array (
'pass' => 'Xss', // do XSS clear before getting this value, see BxDolFormCheckerHelper class for all pass* functions
),
),
'AppetiteOpinion' => array(
'type' => 'select',
'name' => 'AppetiteOpinion',
'caption' => _t("_cf_clients_appetite"),
'values' => array(
'' => '',
'About Right' => 'About Right',
'Poor' => 'Poor',
'Excessive' => 'Excessive',
),
'value' => $AppetiteOpinion,
'required' => true,
// checker params
'checker' => array (
'func' => 'length',
'params' => array(1,25),
'error' => _t('_cf_clients_appetite_err'),
),
'db' => array (
'pass' => 'Xss', // do XSS clear before getting this value, see BxDolFormCheckerHelper class for all pass* functions
),
),
'NutritionOpinion' => array(
'type' => 'select',
'name' => 'NutritionOpinion',
'caption' => _t("_cf_clients_nutrition"),
'values' => array(
'' => '',
'Excellent' => 'Excellent',
'Good' => 'Good',
'Fair' => 'Fair',
'Poor' => 'Poor',
),
'value' => $NutritionOpinion,
'required' => true,
// checker params
'checker' => array (
'func' => 'length',
'params' => array(1,25),
'error' => _t('_cf_clients_nutrition_err'),
),
'db' => array (
'pass' => 'Xss', // do XSS clear before getting this value, see BxDolFormCheckerHelper class for all pass* functions
),
),
'SleepHours' => array(
'type' => 'select',
'name' => 'SleepHours',
'caption' => _t("_cf_clients_sleep_hours"),
'values' => array(
'' => '',
1 => 1,
2 => 2,
3 => 3,
4 => 4,
5 => 5,
6 => 6,
7 => 7,
8 => 8,
9 => 9,
10 => 10,
11 => 11,
12 => 12,
),
'required' => true,
// checker params
'checker' => array (
'func' => 'length',
'params' => array(1,2),
'error' => _t('_cf_clients_sleep_hours_err'),
),
'value' => $SleepHours,
'db' => array (
'pass' => 'Xss', // do XSS clear before getting this value, see BxDolFormCheckerHelper class for all pass* functions
),
),
'SleepHoursOpinion' => array(
'type' => 'select',
'name' => 'SleepHoursOpinion',
'caption' => _t("_cf_clients_sleep_is"),
'values' => array(
'' => '',
'About Right' => 'About Right',
'Too Much' => 'Too Much',
'Too Little' => 'Too Little',
),
'value' => $SleepHoursOpinion,
'required' => true,
// checker params
'checker' => array (
'func' => 'length',
'params' => array(1,255),
'error' => _t('_cf_clients_sleep_is_err'),
),
'db' => array (
'pass' => 'Xss', // do XSS clear before getting this value, see BxDolFormCheckerHelper class for all pass* functions
),
),
'SleepInterferance' => array(
'type' => 'textarea',
'name' => 'SleepInterferance',
'html' => true,
'value' => $SleepInterferance,
'caption' => _t("_cf_clients_sleep_interfernece"),
'required' => true,
'checker' => array (
'func' => 'length',
'params' => array(1,255),
'error' => _t('_cf_clients_sleep_interfernece_err'),
),
'db' => array (
'pass' => 'XssHtml',
),
),
'Dreams' => array(
'type' => 'textarea',
'name' => 'Dreams',
'html' => true,
'caption' => _t("_cf_clients_dreams"),
'value' => $Dreams,
'db' => array (
'pass' => 'Xss', // do XSS clear before getting this value, see BxDolFormCheckerHelper class for all pass* functions
),
),
'KnownMed' => array(
'type' => 'textarea',
'name' => 'KnownMed',
'html' => true,
'caption' => _t("_cf_clients_known_med"),
'value' => $KnownMed,
'db' => array (
'pass' => 'Xss', // do XSS clear before getting this value, see BxDolFormCheckerHelper class for all pass* functions
),
),
'GeneralHealth' => array(
'type' => 'textarea',
'name' => 'GeneralHealth',
'html' => true,
'caption' => _t("_cf_clients_general_health"),
'value' => $GeneralHealth,
'db' => array (
'pass' => 'Xss', // do XSS clear before getting this value, see BxDolFormCheckerHelper class for all pass* functions
),
),
'input_by' => array(
'type' => 'hidden',
'name' => 'input_by', // the same as key and database field name
'value' => $_COOKIE['memberID'],
// database params
'db' => array (
'pass' => 'Xss', // do XSS clear before getting this value, see BxDolFormCheckerHelper class for all pass* functions
),
),
'RecordID' => array(
'type' => 'hidden',
'name' => 'RecordID', // the same as key and database field name
'value' => $RecordID,
// database params
'db' => array (
'pass' => 'Xss', // do XSS clear before getting this value, see BxDolFormCheckerHelper class for all pass* functions
),
),
'client_id' => array(
'type' => 'hidden',
'name' => 'client_id', // the same as key and database field name
'value' => $client,
// database params
'db' => array (
'pass' => 'Xss', // do XSS clear before getting this value, see BxDolFormCheckerHelper class for all pass* functions
),
),
'header1_end' => array(
'type' => 'block_end'
),
'submit_send' => array(
'type' => 'submit',
'colspan' => true,
'name' => 'submit_general_health_form',
'value' => _t("_cf_clients_submit_general_health"),
),
),
);
$oForm = new BxTemplFormView ($aForm);
$oForm->initChecker();
if ($oForm->isSubmittedAndValid ()) {
// add additional vars to database, in this case creation date field is added
$aValsAdd = array (
'client_id' => $client,
);
echo 'insert last id: ' . $oForm->insert ($aValsAdd); // insert validated data to database
}
echo DesignBoxContent(_t('_cf_clients_add_general_health'), $oForm->getCode (), 11);
}
Now, I am not sure if it is because of how the form is displayed or what. Basically, I have a table with a link in the upper right corner of the block to add a new General Health input. Clicking the add link opens the form in the same block that the table was in (photos attached).
Also, although there are required fields, if nothing is entered it still acts like it is submitting - even though it is not submitting nor is it redisplaying the form with errors listed.
Any help would be greatly appreciated. But once I get this issue resolved, there is a second part.