Projet

Général

Profil

Révision 018e218c

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

Weekly update of contrib modules

Voir les différences:

htmltest/sites/all/modules/flag/includes/flag.admin.inc
529 529
    '#title' => t('Flag confirmation message'),
530 530
    '#default_value' => isset($flag->flag_confirmation) ? $flag->flag_confirmation : '',
531 531
    '#description' => t('Message displayed if the user has clicked the "flag this" link and confirmation is required. Usually presented in the form of a question such as, "Are you sure you want to flag this content?"'),
532
    // This will get changed to a state by flag_link_type_options_states().
533
    '#required' => TRUE,
532 534
  );
533 535

  
534 536
  $form['display']['link_options_confirm']['unflag_confirmation'] = array(
......
536 538
    '#title' => t('Unflag confirmation message'),
537 539
    '#default_value' => isset($flag->unflag_confirmation) ? $flag->unflag_confirmation : '',
538 540
    '#description' => t('Message displayed if the user has clicked the "unflag this" link and confirmation is required. Usually presented in the form of a question such as, "Are you sure you want to unflag this content?"'),
541
    // This will get changed to a state by flag_link_type_options_states().
542
    '#required' => TRUE,
539 543
  );
540 544

  
541 545
  $form['actions'] = array(
......
561 565
}
562 566

  
563 567
/**
564
 * FormAPI after_build function set states on link type options fieldsets.
568
 * FormAPI after_build function to set states on link type options fieldsets.
565 569
 *
566 570
 * We do this in an after build so we handle further link types fieldsets from
567 571
 * other modules that provide link types.
......
581 585
          ':input[name="link_type"]' => array('value' => $radio_value),
582 586
        ),
583 587
      );
588

  
589
      // If an element in a link type options fieldset is required, then we
590
      // remove this, as this would break the form, by demanding the user
591
      // enter a value for a form element they possibly can't see!
592
      // Instead, we set the required property as a state.
593
      foreach (element_children($element[$key]) as $child_key) {
594
        if (!empty($element[$key][$child_key]['#required'])) {
595
          $element[$key][$child_key]['#required'] = FALSE;
596
          $element[$key][$child_key]['#states']['required'] = array(
597
            ':input[name="link_type"]' => array('value' => $radio_value),
598
          );
599
        }
600
      }
601

  
584 602
      // Gather up the radio values for the format we need for a multiple
585 603
      // value state.
586 604
      $intro_element_values_array[] = array('value' => $radio_value);
......
635 653
  $form_state['values']['title'] = trim($form_state['values']['title']);
636 654
  $form_values = $form_state['values'];
637 655

  
638
  if ($form_values['link_type'] == 'confirm') {
639
    if (empty($form_values['flag_confirmation'])) {
640
      form_set_error('flag_confirmation', t('A flag confirmation message is required when using the confirmation link type.'));
641
    }
642
    if (empty($form_values['unflag_confirmation'])) {
643
      form_set_error('unflag_confirmation', t('An unflag confirmation message is required when using the confirmation link type.'));
644
    }
645
  }
646

  
647

  
648 656
  $flag = $form['#flag'];
649 657
  $flag->form_input($form_values);
650 658
  $errors = $flag->validate();

Formats disponibles : Unified diff