From fe2b3e7c006a607c2b9fd9a485a7bda13515a94f Mon Sep 17 00:00:00 2001 From: Dries Buytaert Date: Sun, 4 Jul 2004 16:50:02 +0000 Subject: - 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'). --- modules/blog.module | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) (limited to 'modules/blog.module') diff --git a/modules/blog.module b/modules/blog.module index 39dfe52b3..23a73071c 100644 --- a/modules/blog.module +++ b/modules/blog.module @@ -181,16 +181,14 @@ function blog_page_last() { */ function blog_validate(&$node) { if (isset($node->body) && count(explode(' ', $node->body)) < variable_get('minimum_blog_size', 0)) { - $error['body'] = theme('error', t('The body of your blog is too short.')); + form_set_error('body', t('The body of your blog is too short.')); } - - return $error; } /** * Implementation of hook_form(). */ -function blog_form(&$node, &$error) { +function blog_form(&$node) { global $nid; $iid = $_GET['iid']; @@ -214,7 +212,7 @@ function blog_form(&$node, &$error) { $output .= implode('', taxonomy_node_form('blog', $node)); } - $output .= form_textarea(t('Body'), 'body', $node->body, 60, 15, $error['body'] ? $error['body'] : filter_tips_short()); + $output .= form_textarea(t('Body'), 'body', $node->body, 60, 15, filter_tips_short()); return $output; } -- cgit v1.2.3