Projet

Général

Profil

Révision 65389548

Ajouté par Assos Assos il y a plus de 4 ans

Weekly update of contrib modules

Voir les différences:

drupal7/sites/all/modules/webform_validation/webform_validation.admin.inc
173 173
  $form = array();
174 174
  $rule_validator = webform_validation_get_validator_info($validator);
175 175

  
176
  $form['rule'] = array(
177
    '#type' => 'fieldset',
178
    '#title' => ($action == 'edit') ? t('Edit rule') : t('Add rule'),
179
    '#collapsible' => FALSE,
180
    '#collapsed' => FALSE,
181
  );
176
  if ($action === 'edit') {
177
    $title = t('Edit validation rule %title', array('%title' => $rule['rulename']));
178
  }
179
  else {
180
    $title = t('Add validation rule');
181
  }
182
  drupal_set_title($title, PASS_THROUGH);
182 183

  
183 184
  $form['rule']['validator'] = array(
184 185
    '#type' => 'hidden',
......
208 209
    );
209 210
  }
210 211

  
212
  $form['rule']['type'] = array(
213
    '#type' => 'item',
214
    '#title' => t('Rule type'),
215
    '#markup' => $rule_validator['name'],
216
  );
217

  
211 218
  $form['rule']['rulename'] = array(
212 219
    '#type' => 'textfield',
213 220
    '#title' => t('Rule name'),
214
    '#default_value' => (isset($rule['rulename'])) ? $rule['rulename'] : '',
221
    '#default_value' => isset($rule['rulename']) ? $rule['rulename'] : NULL,
215 222
    '#required' => TRUE,
216 223
    '#size' => 60,
217 224
    '#maxlength' => 255,
......
224 231
    '#weight' => 3,
225 232
    '#description' => t('Select the components to be validated by this validation rule'),
226 233
    '#options' => webform_validation_get_webform_components($node, $validator),
227
    '#default_value' => (isset($rule['components'])) ? array_keys($rule['components']) : array(),
234
    '#default_value' => isset($rule['components']) ? array_keys($rule['components']) : array(),
228 235
  );
229 236

  
230 237
  if (!empty($rule_validator['custom_data']) && is_array($rule_validator['custom_data'])) {
......
272 279

  
273 280
  $form['rule']['submit'] = array(
274 281
    '#type' => 'submit',
275
    '#value' => (isset($rule['ruleid'])) ? t('Save rule') : t('Add rule'),
282
    '#value' => isset($rule['ruleid']) ? t('Save rule') : t('Add rule'),
276 283
    '#weight' => 25,
277 284
  );
278 285

  
......
297 304
  }
298 305

  
299 306
  $rule_validator = webform_validation_get_validator_info($values['validator']);
307

  
308
  // Validate custom data.
309
  if ($values['data'] && !empty($rule_validator['custom_data']['validate_regex']) && !preg_match($rule_validator['custom_data']['validate_regex'], $values['data'])) {
310
    form_set_error('data', $rule_validator['custom_data']['label'] . ' ' . t('is invalid.'));
311
  }
312

  
300 313
  $selected_components = count(array_filter($values['rule_components']));
301 314
  // Check validator min_components and min_components property when they are
302 315
  // equal.
303 316
  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']) {
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'));
317
    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.'));
305 318
  }
306 319
  // Check validator min_components property.
307 320
  elseif (isset($rule_validator['min_components']) && $selected_components < $rule_validator['min_components']) {
308
    form_set_error('rule_components', format_plural($rule_validator['min_components'], 'You need to select at least @count component', 'You need to select at least @count components'));
321
    form_set_error('rule_components', format_plural($rule_validator['min_components'], 'You need to select at least @count component.', 'You need to select at least @count components.'));
309 322
  }
310 323
  // Check validator max_components property.
311 324
  elseif (isset($rule_validator['max_components']) && $selected_components > $rule_validator['max_components']) {
312
    form_set_error('rule_components', format_plural($rule_validator['max_components'], 'You can select @count component at most', 'You can select @count components at most'));
325
    form_set_error('rule_components', format_plural($rule_validator['max_components'], 'You can select @count component at most.', 'You can select @count components at most.'));
313 326
  }
314 327
}
315 328

  

Formats disponibles : Unified diff