Commit 16102e80 authored by alexpott's avatar alexpott

Issue #2301587 by joshi.rohit100: Remove form_state_defaults() as it is deprecated.

parent 24cfbec0
......@@ -142,18 +142,6 @@ function drupal_build_form($form_id, &$form_state) {
return \Drupal::formBuilder()->buildForm($form_id, $form_state);
}
/**
* Retrieves default values for the $form_state array.
*
* @deprecated in Drupal 8.x-dev, will be removed before Drupal 8.0.
* Use \Drupal::formBuilder()->getFormStateDefaults().
*
* @see \Drupal\Core\Form\FormBuilderInterface::getFormStateDefaults().
*/
function form_state_defaults() {
return \Drupal::formBuilder()->getFormStateDefaults();
}
/**
* Constructs a new $form from the information in $form_state.
*
......
......@@ -263,7 +263,7 @@ function testEntityFormDisplayBuildForm() {
// Test generating widgets for all fields.
$display = entity_get_form_display($entity_type, $this->instance->bundle, 'default');
$form = array();
$form_state = form_state_defaults();
$form_state = \Drupal::formBuilder()->getFormStateDefaults();
$display->buildForm($entity, $form, $form_state);
$this->assertEqual($form[$this->field_name]['widget']['#title'], $this->instance->getLabel(), "First field's form title is {$this->instance->getLabel()}");
......@@ -285,7 +285,7 @@ function testEntityFormDisplayBuildForm() {
}
}
$form = array();
$form_state = form_state_defaults();
$form_state = \Drupal::formBuilder()->getFormStateDefaults();
$display->buildForm($entity, $form, $form_state);
$this->assertFalse(isset($form[$this->field_name]), 'The first field does not exist in the form');
......@@ -308,7 +308,7 @@ function testEntityFormDisplayExtractFormValues() {
// Build the form for all fields.
$display = entity_get_form_display($entity_type, $this->instance->bundle, 'default');
$form = array();
$form_state = form_state_defaults();
$form_state = \Drupal::formBuilder()->getFormStateDefaults();
$display->buildForm($entity_init, $form, $form_state);
// Simulate incoming values.
......
......@@ -531,7 +531,7 @@ function testFieldFormAccess() {
$display = entity_get_form_display($entity_type, $entity_type, 'default');
$form = array();
$form_state = form_state_defaults();
$form_state = \Drupal::formBuilder()->getFormStateDefaults();
$display->buildForm($entity, $form, $form_state);
$this->assertFalse($form[$field_name_no_access]['#access'], 'Field #access is FALSE for the field without edit access.');
......
......@@ -70,7 +70,7 @@ public function content(Request $request) {
* @throws Symfony\Component\HttpKernel\Exception\HttpExceptionInterface
*/
protected function getForm(Request $request) {
$form_state = form_state_defaults();
$form_state = \Drupal::formBuilder()->getFormStateDefaults();
$form_build_id = $request->request->get('form_build_id');
// Get the form from the cache.
......
......@@ -207,7 +207,7 @@ function testMultipleFalseOptionchecker() {
*/
private function formSubmitHelper($form, $edit) {
$form_id = $this->randomName();
$form_state = form_state_defaults();
$form_state = \Drupal::formBuilder()->getFormStateDefaults();
$form['op'] = array('#type' => 'submit', '#value' => t('Submit'));
// The form token CSRF protection should not interfere with this test, so we
......
......@@ -32,7 +32,7 @@ public function setUp() {
$this->form = array(
'#property' => $this->randomName(),
);
$this->form_state = form_state_defaults();
$this->form_state = \Drupal::formBuilder()->getFormStateDefaults();
$this->form_state['example'] = $this->randomName();
}
......@@ -43,7 +43,7 @@ function testCacheToken() {
\Drupal::currentUser()->setAccount(new UserSession(array('uid' => 1)));
form_set_cache($this->form_build_id, $this->form, $this->form_state);
$cached_form_state = form_state_defaults();
$cached_form_state = \Drupal::formBuilder()->getFormStateDefaults();
$cached_form = form_get_cache($this->form_build_id, $cached_form_state);
$this->assertEqual($this->form['#property'], $cached_form['#property']);
$this->assertTrue(!empty($cached_form['#cache_token']), 'Form has a cache token');
......@@ -53,14 +53,14 @@ function testCacheToken() {
// Change the private key. (We cannot change the session ID because this
// will break the parent site test runner batch.)
\Drupal::state()->set('system.private_key', 'invalid');
$cached_form_state = form_state_defaults();
$cached_form_state = \Drupal::formBuilder()->getFormStateDefaults();
$cached_form = form_get_cache($this->form_build_id, $cached_form_state);
$this->assertFalse($cached_form, 'No form returned from cache');
$this->assertTrue(empty($cached_form_state['example']));
// Test that loading the cache with a different form_id fails.
$wrong_form_build_id = $this->randomName(9);
$cached_form_state = form_state_defaults();
$cached_form_state = \Drupal::formBuilder()->getFormStateDefaults();
$this->assertFalse(form_get_cache($wrong_form_build_id, $cached_form_state), 'No form returned from cache');
$this->assertTrue(empty($cached_form_state['example']), 'Cached form state was not loaded');
}
......@@ -74,7 +74,7 @@ function testNoCacheToken() {
$this->form_state['example'] = $this->randomName();
form_set_cache($this->form_build_id, $this->form, $this->form_state);
$cached_form_state = form_state_defaults();
$cached_form_state = \Drupal::formBuilder()->getFormStateDefaults();
$cached_form = form_get_cache($this->form_build_id, $cached_form_state);
$this->assertEqual($this->form['#property'], $cached_form['#property']);
$this->assertTrue(empty($cached_form['#cache_token']), 'Form has no cache token');
......
......@@ -101,7 +101,7 @@ function testRequiredFields() {
foreach (array(TRUE, FALSE) as $required) {
$form_id = $this->randomName();
$form = array();
$form_state = form_state_defaults();
$form_state = \Drupal::formBuilder()->getFormStateDefaults();
$form['op'] = array('#type' => 'submit', '#value' => t('Submit'));
$element = $data['element']['#title'];
$form[$element] = $data['element'];
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment