Project

General

Profile

« Previous | Next » 

Revision 0aad6e04

Added by Lorna Morris over 12 years ago

modified the error message in dwca_export_config_form_validate to indicate the names of all views that can not be found.

View differences:

7.x/modules/dwca_export/dwca_export.module
135 135
	//drupal_set_message(t('The classification view is ') . $save_variables);// . '<pre>' . print_r($form_state,true) . '</pre>');//$save_variables);
136 136
}
137 137

  
138
// TODO: Modify this so it reports errors in multiple fields. Currently it form_set_error will only indicate if a single view does not exist
138
// Reports an error if view name entered by the user does not exist in the database.
139 139
function dwca_export_config_form_validate($form, &$form_state) {
140 140
	
141 141
	$variables = $form_state['input'];
142 142
	$dwca_export_archive_descriptor_file_map = variable_get(FILE_MAP);
143 143
	$view_names = array();
144
	$missing_view_names = '';
145
	$missing_view = false;
144 146
	
145 147
	foreach ($variables as $key => $value) {
146 148
		
147 149
		if (array_key_exists($key, $dwca_export_archive_descriptor_file_map)) {
148
			//if ($value = 'dwca_export_classification') {
149 150
					
150 151
			$view = views_get_view($value);
151 152
			// check whether there is a view named with this value 
152 153
			if(!$view) {
153
				form_set_error('', t('This view - ' . $value . ' - does not exist. Please input another view name.'));
154
				$view_names[] = $value;
155
				$missing_view_names .= $value . ', ';
156
				$missing_view = true;
154 157
			}
155 158
		}
156 159
	}
157 160
	
161
	if ($missing_view) {
162
		form_set_error('', t('VIEW(S) ' . $missing_view_names . ' NOT FOUND. Please input another view name.'));
163
	}
164
	
158 165
}
159 166

  
160 167
/**

Also available in: Unified diff