diff options
author | Dries Buytaert <dries@buytaert.net> | 2004-05-31 11:51:21 +0000 |
---|---|---|
committer | Dries Buytaert <dries@buytaert.net> | 2004-05-31 11:51:21 +0000 |
commit | 45fdcf8af83a604ce9c768f13e19cd67bf5f20a3 (patch) | |
tree | a1355dc05d8dcc82aa4e17d646fde87ccc39a848 | |
parent | 7f08110a5e29c29812a01b9c148e52b34f3eccdf (diff) | |
download | brdo-45fdcf8af83a604ce9c768f13e19cd67bf5f20a3.tar.gz brdo-45fdcf8af83a604ce9c768f13e19cd67bf5f20a3.tar.bz2 |
- 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 ...
-rw-r--r-- | modules/path.module | 18 | ||||
-rw-r--r-- | modules/path/path.module | 18 |
2 files changed, 18 insertions, 18 deletions
diff --git a/modules/path.module b/modules/path.module index 55e74f22f..a33c524e9 100644 --- a/modules/path.module +++ b/modules/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(); + } } ?> 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(); + } } ?> |