summaryrefslogtreecommitdiff
path: root/modules/poll/poll.module
diff options
context:
space:
mode:
authorDries Buytaert <dries@buytaert.net>2004-07-04 16:50:02 +0000
committerDries Buytaert <dries@buytaert.net>2004-07-04 16:50:02 +0000
commitfe2b3e7c006a607c2b9fd9a485a7bda13515a94f (patch)
tree1c16960253df2c99488fdd8cf81305ff369884d4 /modules/poll/poll.module
parent353c05d01536aac26fec7e9cfee0e84838973286 (diff)
downloadbrdo-fe2b3e7c006a607c2b9fd9a485a7bda13515a94f.tar.gz
brdo-fe2b3e7c006a607c2b9fd9a485a7bda13515a94f.tar.bz2
- Patch by Steven and me: refactored the form handling of nodes. The node system is now using form_set_error() and friends like the rest of Drupal does. This makes for both a consistent user experience and consistent code. It simplifies the forms and validation code, however, it does change the node API slightly:
* The _validate hook and the _nodeapi('validate') hook of the node API (1) no longer take an 'error' parameter and (2) should no longer return an error array. To set an error, call form_set_error(). * The _form hook of the node module no longer takes a form hook and should not worry about displaying errors. Ditto for _nodeapi('form_post') and _nodeapi('form_pre').
Diffstat (limited to 'modules/poll/poll.module')
-rw-r--r--modules/poll/poll.module12
1 files changed, 5 insertions, 7 deletions
diff --git a/modules/poll/poll.module b/modules/poll/poll.module
index b405e245f..78b597d79 100644
--- a/modules/poll/poll.module
+++ b/modules/poll/poll.module
@@ -98,24 +98,22 @@ function poll_validate(&$node) {
}
if ($choice['chvotes'] < 0) {
- $error["choice][$i][chvotes"] = theme('error', t("Negative values are not allowed."));
+ form_set_error("choice][$i][chvotes", t("Negative values are not allowed."));
}
}
if ($realchoices < 2) {
- $error["choice][0][chtext"] = theme('error', t("You must fill in at least two choices."));
+ form_set_error("choice][$realchoices][chtext", t("You must fill in at least two choices."));
}
}
$node->teaser = poll_teaser($node);
-
- return $error;
}
/**
* Implementation of hook_form().
*/
-function poll_form(&$node, &$error) {
+function poll_form(&$node) {
$admin = user_access('administer nodes');
if (function_exists('taxonomy_node_form')) {
@@ -136,9 +134,9 @@ function poll_form(&$node, &$error) {
// Poll choices
$opts = drupal_map_assoc(range(2, $node->choices * 2 + 5));
for ($a = 0; $a < $node->choices; $a++) {
- $group1 .= form_textfield(t('Choice %n', array('%n' => ($a + 1))), "choice][$a][chtext", $node->choice[$a]['chtext'], 50, 127, $error["choice][$a][chtext"]);
+ $group1 .= form_textfield(t('Choice %n', array('%n' => ($a + 1))), "choice][$a][chtext", $node->choice[$a]['chtext'], 50, 127);
if ($admin) {
- $group1 .= form_textfield(t('Votes for choice %n', array('%n' => ($a + 1))), "choice][$a][chvotes", (int)$node->choice[$a]['chvotes'], 7, 7, $error["choice][$a][chvotes"]);
+ $group1 .= form_textfield(t('Votes for choice %n', array('%n' => ($a + 1))), "choice][$a][chvotes", (int)$node->choice[$a]['chvotes'], 7, 7);
}
}
$group1 .= form_hidden('choices', $node->choices);