From 45fdcf8af83a604ce9c768f13e19cd67bf5f20a3 Mon Sep 17 00:00:00 2001 From: Dries Buytaert Date: Mon, 31 May 2004 11:51:21 +0000 Subject: - Updated the form handling to use form_set_error(). All core modules have been updated (almost none have error checking for forms) except the node forms ... --- modules/path/path.module | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'modules/path') diff --git a/modules/path/path.module b/modules/path/path.module index 55e74f22f..a33c524e9 100644 --- a/modules/path/path.module +++ b/modules/path/path.module @@ -272,23 +272,22 @@ function path_save($edit) { $pid = $edit['pid']; if (!valid_url($src)) { - $error = t('the normal path "%src" is invalid.', array('%src' => $src)); + form_set_error('src', t('the normal path "%src" is invalid.', array('%src' => $src))); } if (db_result(db_query("SELECT COUNT(src) FROM {url_alias} WHERE pid != %d AND src = '%s'", $pid, $src))) { - $error = t('the normal path "%src" is already aliased.', array('%src' => $src)); + form_set_error('src', t('the normal path "%src" is already aliased.', array('%src' => $src))); } if (!valid_url($dst)) { - $error = t('the alias "%dst" is invalid.', array('%dst' => $dst)); + form_set_error('dst', t('the alias "%dst" is invalid.', array('%dst' => $dst))); } if (db_result(db_query("SELECT COUNT(dst) FROM {url_alias} WHERE pid != %d AND dst = '%s'", $pid, $dst))) { - $error = t('the alias "%dst" is already in use.', array('%dst' => $dst)); + form_set_error('dst', t('the alias "%dst" is already in use.', array('%dst' => $dst))); } - if ($error) { - drupal_set_message($error, 'error'); + if (form_has_errors()) { return path_form($edit, $error); } else { @@ -302,10 +301,11 @@ function path_save($edit) { else { path_set_alias($src, $dst); } - } - drupal_set_message(t('the alias has been saved.')); - return path_overview(); + drupal_set_message(t('the alias has been saved.')); + + return path_overview(); + } } ?> -- cgit v1.2.3