Projet

Général

Profil

Révision 42e6daf3

Ajouté par Julien Enselme il y a environ 10 ans

Update drupal 7.26 -> 7.27

Voir les différences:

drupal7/modules/simpletest/tests/form_test.module
90 90
    'type' => MENU_CALLBACK,
91 91
  );
92 92

  
93
  $items['form_test/form-storage-legacy'] = array(
94
    'title' => 'Emulate legacy AHAH-style ajax callback',
95
    'page callback' => 'form_test_storage_legacy_handler',
96
    'access arguments' => array('access content'),
97
    'type' => MENU_CALLBACK,
98
  );
99

  
100
  $items['form_test/form-storage-page-cache'] = array(
101
    'title' => 'Form storage with page cache test',
102
    'page callback' => 'drupal_get_form',
103
    'page arguments' => array('form_test_storage_page_cache_form'),
104
    'access arguments' => array('access content'),
105
    'type' => MENU_CALLBACK,
106
  );
107

  
93 108
  $items['form_test/wrapper-callback'] = array(
94 109
    'title' => 'Form wrapper callback test',
95 110
    'page callback' => 'form_test_wrapper_callback',
......
746 761
    $form_state['cache'] = TRUE;
747 762
  }
748 763

  
764
  if (isset($_REQUEST['immutable'])) {
765
    $form_state['build_info']['immutable'] = TRUE;
766
  }
767

  
749 768
  return $form;
750 769
}
751 770

  
771
/**
772
 * Emulate legacy AHAH-style ajax callback.
773
 *
774
 * Drupal 6 AHAH callbacks used to operate directly on forms retrieved using
775
 * form_get_cache and stored using form_set_cache after manipulation. This
776
 * callback helps testing whether form_set_cache prevents resaving of immutable
777
 * forms.
778
 */
779
function form_test_storage_legacy_handler($form_build_id) {
780
  $form_state = array();
781
  $form = form_get_cache($form_build_id, $form_state);
782

  
783
  drupal_json_output(array(
784
    'form' => $form,
785
    'form_state' => $form_state,
786
  ));
787

  
788
  $form['#poisoned'] = TRUE;
789
  $form_state['poisoned'] = TRUE;
790

  
791
  form_set_cache($form_build_id, $form, $form_state);
792
}
793

  
752 794
/**
753 795
 * Form element validation handler for 'value' element in form_test_storage_form().
754 796
 *
......
785 827
  $form_state['redirect'] = 'node';
786 828
}
787 829

  
830
/**
831
 * A simple form for testing form storage when page caching is enabled.
832
 */
833
function form_test_storage_page_cache_form($form, &$form_state) {
834
  $form['title'] = array(
835
    '#type' => 'textfield',
836
    '#title' => 'Title',
837
    '#required' => TRUE,
838
  );
839

  
840
  $form['test_build_id_old'] = array(
841
    '#type' => 'item',
842
    '#title' => 'Old build id',
843
    '#markup' => 'No old build id',
844
  );
845

  
846
  $form['submit'] = array(
847
    '#type' => 'submit',
848
    '#value' => 'Save',
849
  );
850

  
851
  $form['rebuild'] = array(
852
    '#type' => 'submit',
853
    '#value' => 'Rebuild',
854
    '#submit' => array('form_test_storage_page_cache_rebuild'),
855
  );
856

  
857
  $form['#after_build'] = array('form_test_storage_page_cache_old_build_id');
858
  $form_state['cache'] = TRUE;
859

  
860
  return $form;
861
}
862

  
863
/**
864
 * Form element #after_build callback: output the old form build-id.
865
 */
866
function form_test_storage_page_cache_old_build_id($form) {
867
  if (isset($form['#build_id_old'])) {
868
    $form['test_build_id_old']['#markup'] = check_plain($form['#build_id_old']);
869
  }
870
  return $form;
871
}
872

  
873
/**
874
 * Form submit callback: Rebuild the form and continue.
875
 */
876
function form_test_storage_page_cache_rebuild($form, &$form_state) {
877
  $form_state['rebuild'] = TRUE;
878
}
879

  
788 880
/**
789 881
 * A form for testing form labels and required marks.
790 882
 */

Formats disponibles : Unified diff