Go to the source code of this file.
Defines the data integrity checks for the second page of the form.
Definition in file page_2.php.
◆ tpps_page_2_validate_form()
tpps_page_2_validate_form |
( |
array & |
$form, |
|
|
array & |
$form_state |
|
) |
| |
Defines the data integrity checks for the second page of the form.
- Parameters
-
array | $form | The form that is being validated. |
array | $form_state | The state of the form that is being validated. |
Definition at line 16 of file page_2.php.
17 if ($form_state[
'submitted'] ==
'1') {
19 if (!$form_state[
'values'][
'StartingDate'][
'year']) {
20 form_set_error(
'StartingDate][year', t(
'Year: field is required.'));
22 elseif (!$form_state[
'values'][
'StartingDate'][
'month']) {
23 form_set_error(
'StartingDate][month', t(
'Month: field is required.'));
26 if (!$form_state[
'values'][
'EndingDate'][
'year']) {
27 form_set_error(
'EndingDate][year', t(
'Year: field is required.'));
29 elseif (!$form_state[
'values'][
'EndingDate'][
'month']) {
30 form_set_error(
'EndingDate][month', t(
'Month: field is required.'));
33 if (!$form_state[
'values'][
'data_type']) {
34 form_set_error(
'data_type', t(
'Data Type: field is required.'));
37 if (!$form_state[
'values'][
'study_type']) {
38 form_set_error(
'study_type', t(
'Study Type: field is required.'));
41 if (!empty($form_state[
'values'][
'study_info'][
'season'])) {
42 foreach ($form_state[
'values'][
'study_info'][
'season'] as $key => $val) {
44 unset($form_state[
'values'][
'study_info'][
'season'][$key]);
47 if (array_key_exists(
'season', $form_state[
'values'][
'study_info']) and empty($form_state[
'values'][
'study_info'][
'season'])) {
48 form_set_error(
'study_info][season', t(
'Seasons: field is required.'));
52 if (isset($form_state[
'values'][
'study_info'][
'assessions']) and !$form_state[
'values'][
'study_info'][
'assessions']) {
53 form_set_error(
'study_info][assessions', t(
'Number of times the populations were assessed: field is required.'));
56 if (!empty($form_state[
'values'][
'study_info'][
'temp'])) {
57 if (empty($form_state[
'values'][
'study_info'][
'temp'][
'high'])) {
58 form_set_error(
'study_info][temp][high', t(
'Average High Temperature: field is required.'));
60 if (empty($form_state[
'values'][
'study_info'][
'temp'][
'low'])) {
61 form_set_error(
'study_info][temp][low', t(
'Average Low Temperature: field is required.'));
67 'humidity' =>
'Air Humidity',
68 'light' =>
'Light Intensity',
69 'salinity' =>
'Salinity',
72 foreach ($types as $type => $label) {
73 if (!empty($form_state[
'values'][
'study_info'][$type])) {
74 $set = $form_state[
'values'][
'study_info'][$type];
75 if (!$set[
'option']) {
76 form_set_error(
"study_info][$type][option",
"$label controlled or uncontrolled: field is required.");
78 elseif ($set[
'option'] ==
'1' and !$set[
'controlled']) {
79 form_set_error(
"study_info][$type][controlled",
"Controlled $label Value: field is required.");
81 elseif ($set[
'option'] ==
'2' and array_key_exists(
'uncontrolled', $set) and !$set[
'uncontrolled']) {
82 form_set_error(
"study_info][$type][uncontrolled",
"Average $label Value: field is required.");
87 if (!empty($form_state[
'values'][
'study_info'][
'rooting'])) {
88 $root = $form_state[
'values'][
'study_info'][
'rooting'];
89 if (!$root[
'option']) {
90 form_set_error(
"study_info][rooting][option", t(
"Rooting Type: field is required."));
92 elseif ($root[
'option'] ==
'Soil') {
93 if (!$root[
'soil'][
'type']) {
94 form_set_error(
'study_info][rooting][soil][type', t(
'Soil Type: field is required.'));
96 elseif ($root[
'soil'][
'type'] ==
'Other' and !$root[
'soil'][
'other']) {
97 form_set_error(
'study_info][rooting][soil][other', t(
'Custom Soil Type: field is required.'));
100 if (!$root[
'soil'][
'container']) {
101 form_set_error(
'study_info][rooting][soil][type', t(
'Soil Container Type: field is required.'));
106 if (!$ph[
'option']) {
107 form_set_error(
"study_info][rooting][ph][option", t(
"pH controlled or uncontrolled: field is required."));
109 elseif ($ph[
'option'] ==
'1' and !$ph[
'controlled']) {
110 form_set_error(
"study_info][rooting][ph][controlled", t(
"Controlled pH Value: field is required."));
112 elseif ($ph[
'option'] ==
'2' and array_key_exists(
'uncontrolled', $ph) and !$ph[
'uncontrolled']) {
113 form_set_error(
"study_info][rooting][ph][uncontrolled", t(
"Average pH Value: field is required."));
117 $description = FALSE;
119 foreach ($root[
'treatment'] as $field => $value) {
125 elseif ($selected and !$value) {
126 form_set_error(
"study_info][rooting][treatment][$field", t(
"@field: field is required.", array(
'@field' => $field)));
128 $description = FALSE;
132 if (!empty($form_state[
'values'][
'study_info'][
'irrigation'])) {
133 $irrigation = $form_state[
'values'][
'study_info'][
'irrigation'];
134 if (!$irrigation[
'option']) {
135 form_set_error(
'study_info][irrigation][option', t(
'Irrigation Type: field is required.'));
137 elseif ($irrigation[
'option'] ==
'Other' and !$irrigation[
'other']) {
138 form_set_error(
'study_info][irrigation][other', t(
'Custom Irrigation Type: field is required.'));
142 if (!empty($form_state[
'values'][
'study_info'][
'biotic_env']) and preg_match(
'/^0+$/', implode(
'', $form_state[
'values'][
'study_info'][
'biotic_env'][
'option']))) {
143 form_set_error(
'study_info][biotic_env', t(
'Biotic Environment: field is required.'));
145 elseif (!empty($form_state[
'values'][
'study_info'][
'biotic_env'][
'option'][
'Other']) and !$form_state[
'values'][
'study_info'][
'biotic_env'][
'other']) {
146 form_set_error(
'study_info][biotic_env][other', t(
'Custom Biotic Environment: field is required.'));
149 if (!empty($form_state[
'values'][
'study_info'][
'treatment']) and $form_state[
'values'][
'study_info'][
'treatment'][
'check']) {
150 $treatment = $form_state[
'values'][
'study_info'][
'treatment'];
152 $description = FALSE;
153 $treatment_empty = TRUE;
155 foreach ($treatment as $field => $value) {
156 if ($field !=
'check') {
161 $treatment_empty = FALSE;
165 elseif ($selected and !$value) {
166 form_set_error(
"study_info][treatment][$field", t(
"@field: field is required.", array(
'@field' => $field)));
168 $description = FALSE;
172 if ($treatment_empty) {
173 form_set_error(
"study_info][treatment", t(
'Treatment: field is required.'));