Issue #2333353 by ashutoshsngh: Remove usage of form_get_errors().
parent
26564b508c
commit
a2facd2f1b
|
|
@ -382,7 +382,7 @@ abstract class BlockBase extends ContextAwarePluginBase implements BlockPluginIn
|
|||
*/
|
||||
public function submitConfigurationForm(array &$form, FormStateInterface $form_state) {
|
||||
// Process the block's submission handling if no errors occurred only.
|
||||
if (!form_get_errors($form_state)) {
|
||||
if (!$form_state->getErrors()) {
|
||||
$this->configuration['label'] = $form_state->getValue('label');
|
||||
$this->configuration['label_display'] = $form_state->getValue('label_display');
|
||||
$this->configuration['provider'] = $form_state->getValue('provider');
|
||||
|
|
|
|||
|
|
@ -119,7 +119,7 @@ interface FormBuilderInterface {
|
|||
* processes a form, but does not allow you to supply values.
|
||||
*
|
||||
* There is no return value, but you can check to see if there are errors
|
||||
* by calling form_get_errors().
|
||||
* by calling $form_state->getErrors().
|
||||
*
|
||||
* @param \Drupal\Core\Form\FormInterface|string $form_arg
|
||||
* A form object to use to build the form, or the unique string identifying
|
||||
|
|
|
|||
|
|
@ -613,7 +613,7 @@ function comment_preview(CommentInterface $comment, FormStateInterface $form_sta
|
|||
$preview_build = array();
|
||||
$entity = $comment->getCommentedEntity();
|
||||
|
||||
if (!form_get_errors($form_state)) {
|
||||
if (!$form_state->getErrors()) {
|
||||
// Attach the user and time information.
|
||||
$author_name = $comment->getAuthorName();
|
||||
if (!empty($author_name)) {
|
||||
|
|
|
|||
|
|
@ -61,7 +61,7 @@ function datetime_help($route_name, RouteMatchInterface $route_match) {
|
|||
* The current state of the form.
|
||||
*/
|
||||
function datetime_datetime_widget_validate(&$element, FormStateInterface $form_state) {
|
||||
if (!form_get_errors($form_state)) {
|
||||
if (!$form_state->getErrors()) {
|
||||
$input_exists = FALSE;
|
||||
$input = NestedArray::getValue($form_state->getValues(), $element['#parents'], $input_exists);
|
||||
if ($input_exists) {
|
||||
|
|
@ -99,7 +99,7 @@ function datetime_datetime_widget_validate(&$element, FormStateInterface $form_s
|
|||
* The current state of the form.
|
||||
*/
|
||||
function datetime_datelist_widget_validate(&$element, FormStateInterface $form_state) {
|
||||
if (!form_get_errors($form_state)) {
|
||||
if (!$form_state->getErrors()) {
|
||||
$input_exists = FALSE;
|
||||
$input = NestedArray::getValue($form_state->getValues(), $element['#parents'], $input_exists);
|
||||
if ($input_exists) {
|
||||
|
|
|
|||
|
|
@ -223,7 +223,7 @@ class EditorImageDialog extends FormBase {
|
|||
$form_state->setValue(array('attributes', 'alt'), '');
|
||||
}
|
||||
|
||||
if (form_get_errors($form_state)) {
|
||||
if ($form_state->getErrors()) {
|
||||
unset($form['#prefix'], $form['#suffix']);
|
||||
$status_messages = array('#theme' => 'status_messages');
|
||||
$output = drupal_render($form);
|
||||
|
|
|
|||
|
|
@ -83,7 +83,7 @@ class EditorLinkDialog extends FormBase {
|
|||
public function submitForm(array &$form, FormStateInterface $form_state) {
|
||||
$response = new AjaxResponse();
|
||||
|
||||
if (form_get_errors($form_state)) {
|
||||
if ($form_state->getErrors()) {
|
||||
unset($form['#prefix'], $form['#suffix']);
|
||||
$status_messages = array('#theme' => 'status_messages');
|
||||
$output = drupal_render($form);
|
||||
|
|
|
|||
|
|
@ -260,7 +260,7 @@ class NodeForm extends ContentEntityForm {
|
|||
$node = $this->entity;
|
||||
$preview_mode = $this->settings['preview'];
|
||||
|
||||
$element['submit']['#access'] = $preview_mode != DRUPAL_REQUIRED || (!form_get_errors($form_state) && isset($form_state['node_preview']));
|
||||
$element['submit']['#access'] = $preview_mode != DRUPAL_REQUIRED || (!$form_state->getErrors() && isset($form_state['node_preview']));
|
||||
|
||||
// If saving is an option, privileged users get dedicated form submit
|
||||
// buttons to adjust the publishing status while saving in one go.
|
||||
|
|
|
|||
|
|
@ -9,6 +9,7 @@ namespace Drupal\system\Tests\Form;
|
|||
|
||||
use Drupal\Core\Form\FormState;
|
||||
use Drupal\simpletest\WebTestBase;
|
||||
use Drupal\Core\Form\FormStateInterface;
|
||||
|
||||
/**
|
||||
* Tests the tableselect form element for expected behavior.
|
||||
|
|
@ -223,7 +224,7 @@ class ElementsTableSelectTest extends WebTestBase {
|
|||
|
||||
drupal_process_form($form_id, $form, $form_state);
|
||||
|
||||
$errors = form_get_errors($form_state);
|
||||
$errors = $form_state->getErrors();
|
||||
|
||||
// Clear errors and messages.
|
||||
drupal_get_messages();
|
||||
|
|
|
|||
|
|
@ -47,7 +47,7 @@ class FormTest extends WebTestBase {
|
|||
* Carriage returns, tabs, spaces, and unchecked checkbox elements are not
|
||||
* valid content for a required field.
|
||||
*
|
||||
* If the form field is found in form_get_errors() then the test pass.
|
||||
* If the form field is found in $form_state->getErrors() then the test pass.
|
||||
*/
|
||||
function testRequiredFields() {
|
||||
// Originates from http://drupal.org/node/117748
|
||||
|
|
@ -118,7 +118,7 @@ class FormTest extends WebTestBase {
|
|||
$form['#token'] = FALSE;
|
||||
\Drupal::formBuilder()->prepareForm($form_id, $form, $form_state);
|
||||
drupal_process_form($form_id, $form, $form_state);
|
||||
$errors = form_get_errors($form_state);
|
||||
$errors = $form_state->getErrors();
|
||||
// Form elements of type 'radios' throw all sorts of PHP notices
|
||||
// when you try to render them like this, so we ignore those for
|
||||
// testing the required marker.
|
||||
|
|
|
|||
|
|
@ -76,7 +76,7 @@ class ProgrammaticTest extends WebTestBase {
|
|||
\Drupal::formBuilder()->submitForm('\Drupal\form_test\Form\FormTestProgrammaticForm', $form_state);
|
||||
|
||||
// Check that the form returns an error when expected, and vice versa.
|
||||
$errors = form_get_errors($form_state);
|
||||
$errors = $form_state->getErrors();
|
||||
$valid_form = empty($errors);
|
||||
$args = array(
|
||||
'%values' => print_r($values, TRUE),
|
||||
|
|
|
|||
|
|
@ -56,7 +56,7 @@ abstract class SystemConfigFormTestBase extends WebTestBase {
|
|||
\Drupal::formBuilder()->submitForm($this->form, $form_state);
|
||||
|
||||
// Check that the form returns an error when expected, and vice versa.
|
||||
$errors = form_get_errors($form_state);
|
||||
$errors = $form_state->getErrors();
|
||||
$valid_form = empty($errors);
|
||||
$args = array(
|
||||
'%values' => print_r($values, TRUE),
|
||||
|
|
|
|||
|
|
@ -189,7 +189,7 @@ class OverviewTerms extends FormBase {
|
|||
}
|
||||
}
|
||||
|
||||
$errors = form_get_errors($form_state);
|
||||
$errors = $form_state->getErrors();
|
||||
$destination = drupal_get_destination();
|
||||
$row_position = 0;
|
||||
// Build the actual form.
|
||||
|
|
|
|||
|
|
@ -193,7 +193,7 @@ class ConfigHandler extends ViewsFormBase {
|
|||
public function validateForm(array &$form, FormStateInterface $form_state) {
|
||||
$form_state['handler']->validateOptionsForm($form['options'], $form_state);
|
||||
|
||||
if (form_get_errors($form_state)) {
|
||||
if ($form_state->getErrors()) {
|
||||
$form_state['rerender'] = TRUE;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -99,7 +99,7 @@ class Display extends ViewsFormBase {
|
|||
public function validateForm(array &$form, FormStateInterface $form_state) {
|
||||
$form_state['view']->getExecutable()->displayHandlers->get($form_state['display_id'])->validateOptionsForm($form['options'], $form_state);
|
||||
|
||||
if (form_get_errors($form_state)) {
|
||||
if ($form_state->getErrors()) {
|
||||
$form_state['rerender'] = TRUE;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue