summaryrefslogtreecommitdiff
path: root/modules/story/story.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/story/story.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/story/story.module')
-rw-r--r--modules/story/story.module8
1 files changed, 3 insertions, 5 deletions
diff --git a/modules/story/story.module b/modules/story/story.module
index d4bae4ddc..ffc10f0e0 100644
--- a/modules/story/story.module
+++ b/modules/story/story.module
@@ -105,23 +105,21 @@ function story_menu() {
*/
function story_validate(&$node) {
if (isset($node->body) && count(explode(' ', $node->body)) < variable_get('minimum_story_size', 0)) {
- $error['body'] = t('The body of your story is too short. You need at least %word_count words to submit your story.', array('%word_count' => variable_get('minimum_story_size', 0)));
+ form_set_error('body', t('The body of your story is too short. You need at least %word_count words to submit your story.', array('%word_count' => variable_get('minimum_story_size', 0))));
}
-
- return $error;
}
/**
* Implementation of hook_form().
*/
-function story_form(&$node, &$error) {
+function story_form(&$node) {
$output = '';
if (function_exists('taxonomy_node_form')) {
$output .= implode('', taxonomy_node_form('story', $node));
}
- $output .= form_textarea(t('Body'), 'body', $node->body, 60, 15, ($error['body'] ? theme('error', $error['body']) : ''). filter_tips_short());
+ $output .= form_textarea(t('Body'), 'body', $node->body, 60, 15, filter_tips_short());
return $output;
}