Revision 76bdcd04
Added by Assos Assos almost 6 years ago
drupal7/sites/all/modules/webform_validation/webform_validation.admin.inc | ||
---|---|---|
6 | 6 |
*/ |
7 | 7 |
|
8 | 8 |
/** |
9 |
* Menu callback function to show an overview of the existing validation rules, and the option to add a rule. |
|
9 |
* Menu callback function. |
|
10 |
* |
|
11 |
* Shows an overview of the existing validation rules and the option to add a |
|
12 |
* rule. |
|
10 | 13 |
*/ |
11 | 14 |
function webform_validation_manage($node) { |
12 | 15 |
$rules = webform_validation_get_webform_rules($node); |
... | ... | |
153 | 156 |
foreach ($form_state['values'] as $ruleid => $value) { |
154 | 157 |
if (is_numeric($ruleid)) { |
155 | 158 |
$update = db_update('webform_validation_rule') |
156 |
->fields(array(
|
|
157 |
'weight' => $value['weight'],
|
|
158 |
))
|
|
159 |
->condition('ruleid', $ruleid)
|
|
160 |
->execute();
|
|
159 |
->fields(array( |
|
160 |
'weight' => $value['weight'], |
|
161 |
)) |
|
162 |
->condition('ruleid', $ruleid) |
|
163 |
->execute(); |
|
161 | 164 |
} |
162 | 165 |
} |
163 | 166 |
drupal_set_message(t('The order of the validation rules has been saved.')); |
... | ... | |
225 | 228 |
); |
226 | 229 |
|
227 | 230 |
if (!empty($rule_validator['custom_data']) && is_array($rule_validator['custom_data'])) { |
231 |
$valid_types = array('textfield', 'textarea'); |
|
232 |
$type = isset($rule_validator['custom_data']['type']) ? $rule_validator['custom_data']['type'] : 'textfield'; |
|
233 |
if (!in_array($type, $valid_types)) { |
|
234 |
$type = 'textfield'; |
|
235 |
} |
|
236 |
|
|
228 | 237 |
$required = isset($rule_validator['custom_data']['required']) ? $rule_validator['custom_data']['required'] : TRUE; |
229 | 238 |
$form['rule']['data'] = array( |
230 |
'#type' => 'textfield',
|
|
239 |
'#type' => $type,
|
|
231 | 240 |
'#title' => $rule_validator['custom_data']['label'], |
232 | 241 |
'#description' => $rule_validator['custom_data']['description'], |
233 | 242 |
'#required' => (bool) $required, |
... | ... | |
289 | 298 |
|
290 | 299 |
$rule_validator = webform_validation_get_validator_info($values['validator']); |
291 | 300 |
$selected_components = count(array_filter($values['rule_components'])); |
292 |
// Check validator min_components and min_components property when they are equal. |
|
301 |
// Check validator min_components and min_components property when they are |
|
302 |
// equal. |
|
293 | 303 |
if (isset($rule_validator['min_components']) && isset($rule_validator['max_components']) && $rule_validator['min_components'] === $rule_validator['max_components'] && $selected_components !== $rule_validator['min_components']) { |
294 | 304 |
form_set_error('rule_components', format_plural($rule_validator['min_components'], 'You need to select exactly @count component', 'You need to select exactly @count components')); |
295 | 305 |
} |
... | ... | |
312 | 322 |
} |
313 | 323 |
|
314 | 324 |
/** |
315 |
* Get a list of components for a specific webform, filtered by the validator settings. |
|
325 |
* Get a filtered list of components for a specific webform. |
|
326 |
* |
|
327 |
* List is filtered by the validator settings. |
|
316 | 328 |
*/ |
317 | 329 |
function webform_validation_get_webform_components($node, $validator) { |
318 | 330 |
form_load_include($form_state, 'inc', 'webform', 'includes/webform.components'); |
Also available in: Unified diff
Weekly update of contrib modules