Tripal Plant PopGen Submit
page_2.php
Go to the documentation of this file.
1 <?php
2 
8 require_once 'page_2_ajax.php';
9 require_once 'page_2_helper.php';
10 
25 function tpps_page_2_create_form(array &$form, array $form_state) {
26  tpps_study_date('Starting', $form, $form_state);
27 
28  tpps_study_date('Ending', $form, $form_state);
29 
30  $options = array(
31  0 => '- Select -',
32  'Genotype' => 'Genotype',
33  'Phenotype' => 'Phenotype (and/or manual environmental data)',
34  'Genotype x Phenotype' => 'Genotype x Phenotype (and/or manual environmental data)',
35  );
36 
37  if (module_exists('cartogratree') and db_table_exists('cartogratree_groups') and db_table_exists('cartogratree_layers')) {
38  $options = array(
39  0 => '- Select -',
40  'Genotype' => 'Genotype',
41  'Phenotype' => 'Phenotype (and/or manual environmental data)',
42  'Environment' => 'Environmental layers',
43  'Genotype x Phenotype' => 'Genotype x Phenotype (and/or manual environmental data)',
44  'Genotype x Environment' => 'Genotype x Environmental layers',
45  'Phenotype x Environment' => 'Phenotype (and/or manual environmental data) x Environmental layers',
46  'Genotype x Phenotype x Environment' => 'Genotype x Phenotype (and/or manual environmental data) x Environmental layers',
47  );
48  }
49 
50  $form['data_type'] = array(
51  '#type' => 'select',
52  '#title' => t('Data Type: *'),
53  '#options' => $options,
54  '#prefix' => '<legend><span class="fieldset-legend"><div class="fieldset-title">Study Design</div></span></legend>',
55  );
56 
57  $form['study_type'] = array(
58  '#type' => 'select',
59  '#title' => t('Study Type: *'),
60  '#options' => array(
61  0 => t('- Select -'),
62  1 => t('Natural Population (Landscape)'),
63  2 => t('Growth Chamber'),
64  3 => t('Greenhouse'),
65  4 => t('Experimental/Common Garden'),
66  5 => t('Plantation'),
67  ),
68  '#ajax' => array(
69  'wrapper' => 'study_info',
70  'callback' => 'tpps_study_type_callback',
71  ),
72  );
73 
74  $form['study_info'] = array(
75  '#type' => 'fieldset',
76  '#tree' => TRUE,
77  '#collapsible' => TRUE,
78  '#prefix' => '<div id="study_info">',
79  '#suffix' => '</div>',
80  );
81 
82  $type = tpps_get_ajax_value($form_state, array('study_type'), 0);
83 
84  switch ($type) {
85  case '1':
86  tpps_natural_population($form['study_info']);
87  break;
88 
89  case '2':
90  tpps_growth_chamber($form['study_info']);
91  break;
92 
93  case '3':
94  tpps_greenhouse($form['study_info']);
95  unset($form['study_info']['humidity']['uncontrolled']);
96  unset($form['study_info']['light']['uncontrolled']);
97  unset($form['study_info']['rooting']['ph']['uncontrolled']);
98  break;
99 
100  case '4':
101  tpps_common_garden($form['study_info']);
102  break;
103 
104  case '5':
105  tpps_plantation($form['study_info']);
106  break;
107 
108  default:
109  $form['study_info']['#prefix'] = '<div id="study_info" style="display:none;">';
110  break;
111  }
112 
113  $form['Back'] = array(
114  '#type' => 'submit',
115  '#value' => t('Back'),
116  '#prefix' => '<div class="input-description">* : Required Field</div>',
117  );
118 
119  $form['Save'] = array(
120  '#type' => 'submit',
121  '#value' => t('Save'),
122  );
123 
124  $form['Next'] = array(
125  '#type' => 'submit',
126  '#value' => t('Next'),
127  );
128 
129  return $form;
130 }
tpps_get_ajax_value(array &$state, array $parents, $default=NULL, $file_name="")
Definition: form_utils.inc:236
tpps_greenhouse(array &$form)
tpps_common_garden(array &$form)
tpps_study_date($type, array &$form, array &$form_state)
tpps_plantation(array &$form)
tpps_natural_population(array &$form)
tpps_growth_chamber(array &$form)
tpps_page_2_create_form(array &$form, array $form_state)
Definition: page_2.php:25