summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlex Pott2014-08-22 02:04:33 +0100
committerAlex Pott2014-08-22 02:04:33 +0100
commit7fff6e850ab6eb8477c9f018bff35b02005382e9 (patch)
tree89a1d443e89337d90baaa0e78c30fc2dd7e71733
parent92ff38768a6bf8c4c96c37db7aa15203143d56c8 (diff)
Issue #2297875 by herom, bfr: Replace calls to form_set_error() to $form_state->setErrorByName().
-rw-r--r--core/includes/form.inc12
-rw-r--r--core/modules/action/src/Plugin/Action/EmailAction.php2
-rw-r--r--core/modules/color/color.module2
-rw-r--r--core/modules/content_translation/content_translation.admin.inc4
-rw-r--r--core/modules/content_translation/content_translation.module2
-rw-r--r--core/modules/content_translation/src/ContentTranslationHandler.php4
-rw-r--r--core/modules/editor/editor.module2
-rw-r--r--core/modules/file/file.module4
-rw-r--r--core/modules/forum/forum.module4
-rw-r--r--core/modules/image/src/Plugin/ImageEffect/RotateImageEffect.php2
-rw-r--r--core/modules/image/src/Plugin/ImageEffect/ScaleImageEffect.php2
-rw-r--r--core/modules/menu_ui/menu_ui.module2
-rw-r--r--core/modules/node/node.api.php4
-rw-r--r--core/modules/node/src/Plugin/Action/AssignOwnerNode.php2
-rw-r--r--core/modules/rest/src/Plugin/views/row/DataFieldRow.php2
-rw-r--r--core/modules/search/src/Plugin/views/filter/Search.php2
-rw-r--r--core/modules/system/src/Plugin/views/field/BulkForm.php2
-rw-r--r--core/modules/system/system.module9
-rw-r--r--core/modules/system/tests/modules/form_test/src/Callbacks.php2
-rw-r--r--core/modules/system/tests/modules/form_test/src/Form/FormTestProgrammaticForm.php2
-rw-r--r--core/modules/system/tests/modules/form_test/src/Form/FormTestValidateForm.php2
-rw-r--r--core/modules/user/user.module4
-rw-r--r--core/modules/views/src/Plugin/views/filter/BooleanOperator.php2
-rw-r--r--core/modules/views/src/Plugin/views/filter/Combine.php2
-rw-r--r--core/modules/views/src/Plugin/views/pager/SqlBase.php6
25 files changed, 37 insertions, 46 deletions
diff --git a/core/includes/form.inc b/core/includes/form.inc
index 53e7c6b..11da7bf 100644
--- a/core/includes/form.inc
+++ b/core/includes/form.inc
@@ -136,18 +136,6 @@ function form_execute_handlers($type, &$form, FormStateInterface $form_state) {
}
/**
- * Files an error against a form element.
- *
- * @deprecated in Drupal 8.x-dev, will be removed before Drupal 8.0.
- * Use $form_state->setErrorByName().
- *
- * @see \Drupal\Core\Form\FormStateInterface::setErrorByName().
- */
-function form_set_error($name, FormStateInterface $form_state, $message = '') {
- $form_state->setErrorByName($name, $message);
-}
-
-/**
* Returns an associative array of all errors.
*
* @deprecated in Drupal 8.x-dev, will be removed before Drupal 8.0.
diff --git a/core/modules/action/src/Plugin/Action/EmailAction.php b/core/modules/action/src/Plugin/Action/EmailAction.php
index 1c67123..58409d1 100644
--- a/core/modules/action/src/Plugin/Action/EmailAction.php
+++ b/core/modules/action/src/Plugin/Action/EmailAction.php
@@ -159,7 +159,7 @@ class EmailAction extends ConfigurableActionBase implements ContainerFactoryPlug
public function validateConfigurationForm(array &$form, FormStateInterface $form_state) {
if (!valid_email_address($form_state->getValue('recipient')) && strpos($form_state->getValue('recipient'), ':mail') === FALSE) {
// We want the literal %author placeholder to be emphasized in the error message.
- form_set_error('recipient', $form_state, t('Enter a valid email address or use a token email address such as %author.', array('%author' => '[node:author:mail]')));
+ $form_state->setErrorByName('recipient', t('Enter a valid email address or use a token email address such as %author.', array('%author' => '[node:author:mail]')));
}
}
diff --git a/core/modules/color/color.module b/core/modules/color/color.module
index ae63364..44a2a7a 100644
--- a/core/modules/color/color.module
+++ b/core/modules/color/color.module
@@ -334,7 +334,7 @@ function color_scheme_form_validate($form, FormStateInterface $form_state) {
// Only accept hexadecimal CSS color strings to avoid XSS upon use.
foreach ($form_state->getValue('palette') as $key => $color) {
if (!color_valid_hexadecimal_string($color)) {
- form_set_error('palette][' . $key, $form_state, t('You must enter a valid hexadecimal color value for %name.', array('%name' => $form['color']['palette'][$key]['#title'])));
+ $form_state->setErrorByName('palette][' . $key, t('You must enter a valid hexadecimal color value for %name.', array('%name' => $form['color']['palette'][$key]['#title'])));
}
}
}
diff --git a/core/modules/content_translation/content_translation.admin.inc b/core/modules/content_translation/content_translation.admin.inc
index 768b891..36ac92e 100644
--- a/core/modules/content_translation/content_translation.admin.inc
+++ b/core/modules/content_translation/content_translation.admin.inc
@@ -264,7 +264,7 @@ function content_translation_form_language_content_settings_validate(array $form
$translatable_fields = isset($settings[$entity_type][$bundle]['fields']) ? array_filter($settings[$entity_type][$bundle]['fields']) : FALSE;
if (empty($translatable_fields)) {
$t_args = array('%bundle' => $form['settings'][$entity_type][$bundle]['settings']['#label']);
- form_set_error($name, $form_state, t('At least one field needs to be translatable to enable %bundle for translation.', $t_args));
+ $form_state->setErrorByName($name, t('At least one field needs to be translatable to enable %bundle for translation.', $t_args));
}
$values = $bundle_settings['settings']['language'];
@@ -272,7 +272,7 @@ function content_translation_form_language_content_settings_validate(array $form
foreach (\Drupal::languageManager()->getLanguages(LanguageInterface::STATE_LOCKED) as $language) {
$locked_languages[] = $language->name;
}
- form_set_error($name, $form_state, t('Translation is not supported if language is always one of: @locked_languages', array('@locked_languages' => implode(', ', $locked_languages))));
+ $form_state->setErrorByName($name, t('Translation is not supported if language is always one of: @locked_languages', array('@locked_languages' => implode(', ', $locked_languages))));
}
}
}
diff --git a/core/modules/content_translation/content_translation.module b/core/modules/content_translation/content_translation.module
index d8b2819..fe9042d 100644
--- a/core/modules/content_translation/content_translation.module
+++ b/core/modules/content_translation/content_translation.module
@@ -753,7 +753,7 @@ function content_translation_language_configuration_element_validate($element, F
// @todo Set the correct form element name as soon as the element parents
// are correctly set. We should be using NestedArray::getValue() but for
// now we cannot.
- form_set_error('', $form_state, t('"Show language selector" is not compatible with translating content that has default language: %choice. Either do not hide the language selector or pick a specific language.', array('%choice' => $locked_languages[$values['langcode']])));
+ $form_state->setErrorByName('', t('"Show language selector" is not compatible with translating content that has default language: %choice. Either do not hide the language selector or pick a specific language.', array('%choice' => $locked_languages[$values['langcode']])));
}
}
diff --git a/core/modules/content_translation/src/ContentTranslationHandler.php b/core/modules/content_translation/src/ContentTranslationHandler.php
index cba41ae..c1f638f 100644
--- a/core/modules/content_translation/src/ContentTranslationHandler.php
+++ b/core/modules/content_translation/src/ContentTranslationHandler.php
@@ -420,11 +420,11 @@ class ContentTranslationHandler implements ContentTranslationHandlerInterface {
$translation = $form_state->getValue('content_translation');
// Validate the "authored by" field.
if (!empty($translation['name']) && !($account = user_load_by_name($translation['name']))) {
- form_set_error('content_translation][name', $form_state, t('The translation authoring username %name does not exist.', array('%name' => $translation['name'])));
+ $form_state->setErrorByName('content_translation][name', t('The translation authoring username %name does not exist.', array('%name' => $translation['name'])));
}
// Validate the "authored on" field.
if (!empty($translation['created']) && strtotime($translation['created']) === FALSE) {
- form_set_error('content_translation][created', $form_state, t('You have to specify a valid translation authoring date.'));
+ $form_state->setErrorByName('content_translation][created', t('You have to specify a valid translation authoring date.'));
}
}
}
diff --git a/core/modules/editor/editor.module b/core/modules/editor/editor.module
index 3e2804d..ce3b9fa 100644
--- a/core/modules/editor/editor.module
+++ b/core/modules/editor/editor.module
@@ -207,7 +207,7 @@ function editor_form_filter_admin_format_validate($form, FormStateInterface $for
// selected a text editor and has then clicked 'Save configuration', we should
// point out that the user must still configure the text editor.
if ($form_state->getValue(array('editor', 'editor')) !== '' && empty($form_state['editor'])) {
- form_set_error('editor][editor', $form_state, t('You must configure the selected text editor.'));
+ $form_state->setErrorByName('editor][editor', t('You must configure the selected text editor.'));
}
}
diff --git a/core/modules/file/file.module b/core/modules/file/file.module
index 825594e..af6ccab 100644
--- a/core/modules/file/file.module
+++ b/core/modules/file/file.module
@@ -1446,7 +1446,7 @@ function file_managed_file_save_upload($element, FormStateInterface $form_state)
$destination = isset($element['#upload_location']) ? $element['#upload_location'] : NULL;
if (isset($destination) && !file_prepare_directory($destination, FILE_CREATE_DIRECTORY)) {
\Drupal::logger('file')->notice('The upload directory %directory for the file field !name could not be created or is not accessible. A newly uploaded file could not be saved in this directory as a consequence, and the upload was canceled.', array('%directory' => $destination, '!name' => $element['#field_name']));
- form_set_error($upload_name, $form_state, t('The file could not be uploaded.'));
+ $form_state->setErrorByName($upload_name, t('The file could not be uploaded.'));
return FALSE;
}
@@ -1456,7 +1456,7 @@ function file_managed_file_save_upload($element, FormStateInterface $form_state)
if ($files_uploaded) {
if (!$files = file_save_upload($upload_name, $element['#upload_validators'], $destination)) {
\Drupal::logger('file')->notice('The file upload failed. %upload', array('%upload' => $upload_name));
- form_set_error($upload_name, $form_state, t('Files in the !name field were unable to be uploaded.', array('!name' => $element['#title'])));
+ $form_state->setErrorByName($upload_name, t('Files in the !name field were unable to be uploaded.', array('!name' => $element['#title'])));
return array();
}
diff --git a/core/modules/forum/forum.module b/core/modules/forum/forum.module
index d30c85b..ed2f05a 100644
--- a/core/modules/forum/forum.module
+++ b/core/modules/forum/forum.module
@@ -213,7 +213,7 @@ function forum_node_validate(EntityInterface $node, $form, FormStateInterface $f
}
$term = $item->entity;
if (!$term) {
- form_set_error('taxonomy_forums', $form_state, t('Select a forum.'));
+ $form_state->setErrorByName('taxonomy_forums', t('Select a forum.'));
continue;
}
$used = \Drupal::entityQuery('taxonomy_term')
@@ -223,7 +223,7 @@ function forum_node_validate(EntityInterface $node, $form, FormStateInterface $f
->count()
->execute();
if ($used && !empty($term->forum_container->value)) {
- form_set_error('taxonomy_forums', $form_state, t('The item %forum is a forum container, not a forum. Select one of the forums below instead.', array('%forum' => $term->getName())));
+ $form_state->setErrorByName('taxonomy_forums', t('The item %forum is a forum container, not a forum. Select one of the forums below instead.', array('%forum' => $term->getName())));
}
}
}
diff --git a/core/modules/image/src/Plugin/ImageEffect/RotateImageEffect.php b/core/modules/image/src/Plugin/ImageEffect/RotateImageEffect.php
index 078dbf6..3995011 100644
--- a/core/modules/image/src/Plugin/ImageEffect/RotateImageEffect.php
+++ b/core/modules/image/src/Plugin/ImageEffect/RotateImageEffect.php
@@ -129,7 +129,7 @@ class RotateImageEffect extends ConfigurableImageEffectBase {
*/
public function validateConfigurationForm(array &$form, FormStateInterface $form_state) {
if (!$form_state->isValueEmpty('bgcolor') && !Color::validateHex($form_state->getValue('bgcolor'))) {
- form_set_error('bgcolor', $form_state, $this->t('Background color must be a hexadecimal color value.'));
+ $form_state->setErrorByName('bgcolor', $this->t('Background color must be a hexadecimal color value.'));
}
}
diff --git a/core/modules/image/src/Plugin/ImageEffect/ScaleImageEffect.php b/core/modules/image/src/Plugin/ImageEffect/ScaleImageEffect.php
index 338be49..0b9bece 100644
--- a/core/modules/image/src/Plugin/ImageEffect/ScaleImageEffect.php
+++ b/core/modules/image/src/Plugin/ImageEffect/ScaleImageEffect.php
@@ -86,7 +86,7 @@ class ScaleImageEffect extends ResizeImageEffect {
public function validateConfigurationForm(array &$form, FormStateInterface $form_state) {
parent::validateConfigurationForm($form, $form_state);
if ($form_state->isValueEmpty('width') && $form_state->isValueEmpty('height')) {
- form_set_error('data', $form_state, $this->t('Width and height can not both be blank.'));
+ $form_state->setErrorByName('data', $this->t('Width and height can not both be blank.'));
}
}
diff --git a/core/modules/menu_ui/menu_ui.module b/core/modules/menu_ui/menu_ui.module
index 76aee08..e9a381e 100644
--- a/core/modules/menu_ui/menu_ui.module
+++ b/core/modules/menu_ui/menu_ui.module
@@ -501,7 +501,7 @@ function menu_ui_form_node_type_form_validate(&$form, FormStateInterface $form_s
if (count($available_menus)) {
$menu_item_id_parts = explode(':', $form_state->getValue('menu_parent'));
if (!in_array($menu_item_id_parts[0], $available_menus)) {
- form_set_error('menu_parent', $form_state, t('The selected menu item is not under one of the selected menus.'));
+ $form_state->setErrorByName('menu_parent', t('The selected menu item is not under one of the selected menus.'));
}
}
else {
diff --git a/core/modules/node/node.api.php b/core/modules/node/node.api.php
index 7238abe..6fb311c 100644
--- a/core/modules/node/node.api.php
+++ b/core/modules/node/node.api.php
@@ -405,7 +405,7 @@ function hook_node_update_index(\Drupal\node\NodeInterface $node, $langcode) {
* finished editing the node and is previewing or submitting it. It is invoked
* at the end of all the standard validation steps.
*
- * To indicate a validation error, use form_set_error().
+ * To indicate a validation error, use $form_state->setErrorByName().
*
* Note: Changes made to the $node object within your hook implementation will
* have no effect. The preferred method to change a node's content is to use
@@ -424,7 +424,7 @@ function hook_node_update_index(\Drupal\node\NodeInterface $node, $langcode) {
function hook_node_validate(\Drupal\node\NodeInterface $node, $form, \Drupal\Core\Form\FormStateInterface $form_state) {
if (isset($node->end) && isset($node->start)) {
if ($node->start > $node->end) {
- form_set_error('time', $form_state, t('An event may not end before it starts.'));
+ $form_state->setErrorByName('time', t('An event may not end before it starts.'));
}
}
}
diff --git a/core/modules/node/src/Plugin/Action/AssignOwnerNode.php b/core/modules/node/src/Plugin/Action/AssignOwnerNode.php
index 8618fd68..17e62d1 100644
--- a/core/modules/node/src/Plugin/Action/AssignOwnerNode.php
+++ b/core/modules/node/src/Plugin/Action/AssignOwnerNode.php
@@ -121,7 +121,7 @@ class AssignOwnerNode extends ConfigurableActionBase implements ContainerFactory
public function validateConfigurationForm(array &$form, FormStateInterface $form_state) {
$exists = (bool) $this->connection->queryRange('SELECT 1 FROM {users_field_data} WHERE name = :name AND default_langcode = 1', 0, 1, array(':name' => $form_state->getValue('owner_name')))->fetchField();
if (!$exists) {
- form_set_error('owner_name', $form_state, t('Enter a valid username.'));
+ $form_state->setErrorByName('owner_name', t('Enter a valid username.'));
}
}
diff --git a/core/modules/rest/src/Plugin/views/row/DataFieldRow.php b/core/modules/rest/src/Plugin/views/row/DataFieldRow.php
index 821ed48..6f6a629 100644
--- a/core/modules/rest/src/Plugin/views/row/DataFieldRow.php
+++ b/core/modules/rest/src/Plugin/views/row/DataFieldRow.php
@@ -128,7 +128,7 @@ class DataFieldRow extends RowPluginBase {
// If array filter returns empty, no values have been entered. Unique keys
// should only be validated if we have some.
if (($filtered = array_filter($aliases)) && (array_unique($filtered) !== $filtered)) {
- form_set_error('aliases', $form_state, t('All field aliases must be unique'));
+ $form_state->setErrorByName('aliases', t('All field aliases must be unique'));
}
}
diff --git a/core/modules/search/src/Plugin/views/filter/Search.php b/core/modules/search/src/Plugin/views/filter/Search.php
index 20d60b6..7635125 100644
--- a/core/modules/search/src/Plugin/views/filter/Search.php
+++ b/core/modules/search/src/Plugin/views/filter/Search.php
@@ -108,7 +108,7 @@ class Search extends FilterPluginBase {
if (!$form_state->isValueEmpty($key)) {
$this->queryParseSearchExpression($form_state->getValue($key));
if (count($this->searchQuery->words()) == 0) {
- form_set_error($key, $form_state, format_plural(\Drupal::config('search.settings')->get('index.minimum_word_size'), 'You must include at least one positive keyword with 1 character or more.', 'You must include at least one positive keyword with @count characters or more.'));
+ $form_state->setErrorByName($key, format_plural(\Drupal::config('search.settings')->get('index.minimum_word_size'), 'You must include at least one positive keyword with 1 character or more.', 'You must include at least one positive keyword with @count characters or more.'));
}
}
}
diff --git a/core/modules/system/src/Plugin/views/field/BulkForm.php b/core/modules/system/src/Plugin/views/field/BulkForm.php
index 130dc33..bae235d 100644
--- a/core/modules/system/src/Plugin/views/field/BulkForm.php
+++ b/core/modules/system/src/Plugin/views/field/BulkForm.php
@@ -294,7 +294,7 @@ class BulkForm extends FieldPluginBase {
public function viewsFormValidate(&$form, FormStateInterface $form_state) {
$selected = array_filter($form_state->getValue($this->options['id']));
if (empty($selected)) {
- form_set_error('', $form_state, $this->emptySelectedMessage());
+ $form_state->setErrorByName('', $this->emptySelectedMessage());
}
}
diff --git a/core/modules/system/system.module b/core/modules/system/system.module
index aceb805..c956e4d 100644
--- a/core/modules/system/system.module
+++ b/core/modules/system/system.module
@@ -8,6 +8,7 @@
use Drupal\Core\Cache\Cache;
use Drupal\Core\Extension\Extension;
use Drupal\Core\Extension\ExtensionDiscovery;
+use Drupal\Core\Form\FormState;
use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\Routing\RouteMatchInterface;
use Drupal\Core\StringTranslation\TranslationWrapper;
@@ -1090,8 +1091,10 @@ function system_preprocess_block(&$variables) {
*
* @param $form_element
* The form element containing the name of the directory to check.
+ * @param \Drupal\Core\Form\FormStateInterface $form_state
+ * The current state of the form.
*/
-function system_check_directory($form_element) {
+function system_check_directory($form_element, FormStateInterface $form_state) {
$directory = $form_element['#value'];
if (strlen($directory) == 0) {
return $form_element;
@@ -1100,13 +1103,13 @@ function system_check_directory($form_element) {
$logger = \Drupal::logger('file system');
if (!is_dir($directory) && !drupal_mkdir($directory, NULL, TRUE)) {
// If the directory does not exists and cannot be created.
- form_set_error($form_element['#parents'][0], $form_state, t('The directory %directory does not exist and could not be created.', array('%directory' => $directory)));
+ $form_state->setErrorByName($form_element['#parents'][0], t('The directory %directory does not exist and could not be created.', array('%directory' => $directory)));
$logger->error('The directory %directory does not exist and could not be created.', array('%directory' => $directory));
}
if (is_dir($directory) && !is_writable($directory) && !drupal_chmod($directory)) {
// If the directory is not writable and cannot be made so.
- form_set_error($form_element['#parents'][0], $form_state, t('The directory %directory exists but is not writable and could not be made writable.', array('%directory' => $directory)));
+ $form_state->setErrorByName($form_element['#parents'][0], t('The directory %directory exists but is not writable and could not be made writable.', array('%directory' => $directory)));
$logger->error('The directory %directory exists but is not writable and could not be made writable.', array('%directory' => $directory));
}
elseif (is_dir($directory)) {
diff --git a/core/modules/system/tests/modules/form_test/src/Callbacks.php b/core/modules/system/tests/modules/form_test/src/Callbacks.php
index bababe6..ed26dd9 100644
--- a/core/modules/system/tests/modules/form_test/src/Callbacks.php
+++ b/core/modules/system/tests/modules/form_test/src/Callbacks.php
@@ -46,7 +46,7 @@ class Callbacks {
drupal_set_message(t('@label value: @value', array('@label' => $element['#title'], '@value' => $form_state->getValue('name'))));
// Trigger a form validation error to see our changes.
- form_set_error('', $form_state);
+ $form_state->setErrorByName('');
}
}
diff --git a/core/modules/system/tests/modules/form_test/src/Form/FormTestProgrammaticForm.php b/core/modules/system/tests/modules/form_test/src/Form/FormTestProgrammaticForm.php
index d782ef5..f7d6150 100644
--- a/core/modules/system/tests/modules/form_test/src/Form/FormTestProgrammaticForm.php
+++ b/core/modules/system/tests/modules/form_test/src/Form/FormTestProgrammaticForm.php
@@ -90,7 +90,7 @@ class FormTestProgrammaticForm extends FormBase {
*/
public function validateForm(array &$form, FormStateInterface $form_state) {
if ($form_state->isValueEmpty('textfield')) {
- form_set_error('textfield', $form_state, t('Textfield is required.'));
+ $form_state->setErrorByName('textfield', t('Textfield is required.'));
}
}
diff --git a/core/modules/system/tests/modules/form_test/src/Form/FormTestValidateForm.php b/core/modules/system/tests/modules/form_test/src/Form/FormTestValidateForm.php
index 27f31ed..d9293b4 100644
--- a/core/modules/system/tests/modules/form_test/src/Form/FormTestValidateForm.php
+++ b/core/modules/system/tests/modules/form_test/src/Form/FormTestValidateForm.php
@@ -69,7 +69,7 @@ class FormTestValidateForm extends FormBase {
drupal_set_message(t('@label value: @value', array('@label' => $form['name']['#title'], '@value' => $form_state->getValue('name'))));
// Trigger a form validation error to see our changes.
- form_set_error('', $form_state);
+ $form_state->setErrorByName('');
}
}
diff --git a/core/modules/user/user.module b/core/modules/user/user.module
index 8516792..f2b1984 100644
--- a/core/modules/user/user.module
+++ b/core/modules/user/user.module
@@ -507,8 +507,8 @@ function user_validate_current_pass(&$form, FormStateInterface $form_state) {
if ((strlen(trim($form_state->getValue($key))) > 0) && ($form_state->getValue($key) != $current_value)) {
$current_pass_failed = $form_state->isValueEmpty('current_pass') || !\Drupal::service('password')->check($form_state->getValue('current_pass'), $account);
if ($current_pass_failed) {
- form_set_error('current_pass', $form_state, t("Your current password is missing or incorrect; it's required to change the %name.", array('%name' => $name)));
- form_set_error($key, $form_state);
+ $form_state->setErrorByName('current_pass', t("Your current password is missing or incorrect; it's required to change the %name.", array('%name' => $name)));
+ $form_state->setErrorByName($key);
}
// We only need to check the password once.
break;
diff --git a/core/modules/views/src/Plugin/views/filter/BooleanOperator.php b/core/modules/views/src/Plugin/views/filter/BooleanOperator.php
index c635eb6..3db2233 100644
--- a/core/modules/views/src/Plugin/views/filter/BooleanOperator.php
+++ b/core/modules/views/src/Plugin/views/filter/BooleanOperator.php
@@ -165,7 +165,7 @@ class BooleanOperator extends FilterPluginBase {
protected function valueValidate($form, FormStateInterface $form_state) {
if ($form_state->getValue(array('options', 'value')) == 'All' && !$form_state->isValueEmpty(array('options', 'expose', 'required'))) {
- form_set_error('value', $form_state, t('You must select a value unless this is an non-required exposed filter.'));
+ $form_state->setErrorByName('value', t('You must select a value unless this is an non-required exposed filter.'));
}
}
diff --git a/core/modules/views/src/Plugin/views/filter/Combine.php b/core/modules/views/src/Plugin/views/filter/Combine.php
index 12e6f22..7751027 100644
--- a/core/modules/views/src/Plugin/views/filter/Combine.php
+++ b/core/modules/views/src/Plugin/views/filter/Combine.php
@@ -51,7 +51,7 @@ class Combine extends String {
);
}
else {
- form_set_error('', $form_state, t('You have to add some fields to be able to use this filter.'));
+ $form_state->setErrorByName('', t('You have to add some fields to be able to use this filter.'));
}
}
}
diff --git a/core/modules/views/src/Plugin/views/pager/SqlBase.php b/core/modules/views/src/Plugin/views/pager/SqlBase.php
index 1fe68bc..8a4a8e54d 100644
--- a/core/modules/views/src/Plugin/views/pager/SqlBase.php
+++ b/core/modules/views/src/Plugin/views/pager/SqlBase.php
@@ -197,14 +197,14 @@ abstract class SqlBase extends PagerPluginBase {
$error = TRUE;
}
if ($error) {
- form_set_error('pager_options][expose][items_per_page_options', $form_state, t('Insert a list of integer numeric values separated by commas: e.g: 10, 20, 50, 100'));
+ $form_state->setErrorByName('pager_options][expose][items_per_page_options', t('Insert a list of integer numeric values separated by commas: e.g: 10, 20, 50, 100'));
}
// Make sure that the items_per_page is part of the expose settings.
if (!$form_state->isValueEmpty(array('pager_options', 'expose', 'items_per_page')) && !$form_state->isValueEmpty(array('pager_options', 'items_per_page'))) {
$items_per_page = $form_state->getValue(array('pager_options', 'items_per_page'));
if (array_search($items_per_page, $options) === FALSE) {
- form_set_error('pager_options][expose][items_per_page_options', $form_state, t("The <em>Exposed items per page</em> field's options must include the value from the <em>Items per page</em> field (@items_per_page).",
+ $form_state->setErrorByName('pager_options][expose][items_per_page_options', t("The <em>Exposed items per page</em> field's options must include the value from the <em>Items per page</em> field (@items_per_page).",
array('@items_per_page' => $items_per_page))
);
}
@@ -371,7 +371,7 @@ abstract class SqlBase extends PagerPluginBase {
public function exposedFormValidate(&$form, FormStateInterface $form_state) {
if (!$form_state->isValueEmpty('offset') && trim($form_state->getValue('offset'))) {
if (!is_numeric($form_state->getValue('offset')) || $form_state->getValue('offset') < 0) {
- form_set_error('offset', $form_state, t('Offset must be an number greather or equal than 0.'));
+ $form_state->setErrorByName('offset', t('Offset must be an number greather or equal than 0.'));
}
}
}