Révision 389fb945
Ajouté par Assos Assos il y a environ 5 ans
drupal7/sites/all/modules/webform/components/date.inc | ||
---|---|---|
407 | 407 |
* Element validation for Webform date fields. |
408 | 408 |
*/ |
409 | 409 |
function webform_validate_date($element, $form_state) { |
410 |
$field_types = array('day', 'month', 'year');
|
|
410 |
$date_parts = array('day', 'month', 'year');
|
|
411 | 411 |
|
412 | 412 |
// Determine if the user has specified a date. Hidden parts of the date will |
413 | 413 |
// be submitted automatically. |
414 |
foreach ($field_types as $field_type) {
|
|
415 |
if (!in_array($field_type, $element['#exclude']) && $element[$field_type]['#value'] !== '') {
|
|
414 |
foreach ($date_parts as $date_part) {
|
|
415 |
if (!in_array($date_part, $element['#exclude']) && $element[$date_part]['#value'] !== '') {
|
|
416 | 416 |
$field_found = TRUE; |
417 | 417 |
} |
418 | 418 |
} |
419 | 419 |
|
420 | 420 |
if (isset($field_found)) { |
421 | 421 |
// Check that each part of the date has been filled in. |
422 |
foreach ($field_types as $field_type) {
|
|
423 |
if (empty($element[$field_type]['#value'])) {
|
|
424 |
form_error($element[$field_type], t('!part in !name is missing.', array('!name' => $element['#title'], '!part' => $element[$field_type]['#title'])));
|
|
422 |
foreach ($date_parts as $date_part) {
|
|
423 |
if (empty($element[$date_part]['#value'])) {
|
|
424 |
form_error($element[$date_part], t('!part in !name is missing.', array('!name' => $element['#title'], '!part' => $element[$date_part]['#title'])));
|
|
425 | 425 |
$missing_fields = TRUE; |
426 | 426 |
} |
427 | 427 |
} |
... | ... | |
430 | 430 |
} |
431 | 431 |
|
432 | 432 |
// Ensure date is made up of integers. |
433 |
foreach (array('year', 'month', 'day') as $date_part) {
|
|
433 |
foreach ($date_parts as $date_part) {
|
|
434 | 434 |
$element[$date_part]['#value'] = (int) $element[$date_part]['#value']; |
435 | 435 |
} |
436 | 436 |
|
Formats disponibles : Unified diff
Weekly update of contrib modules