diff options
author | Dries Buytaert <dries@buytaert.net> | 2004-07-04 16:50:02 +0000 |
---|---|---|
committer | Dries Buytaert <dries@buytaert.net> | 2004-07-04 16:50:02 +0000 |
commit | fe2b3e7c006a607c2b9fd9a485a7bda13515a94f (patch) | |
tree | 1c16960253df2c99488fdd8cf81305ff369884d4 /modules/forum/forum.module | |
parent | 353c05d01536aac26fec7e9cfee0e84838973286 (diff) | |
download | brdo-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/forum/forum.module')
-rw-r--r-- | modules/forum/forum.module | 7 |
1 files changed, 3 insertions, 4 deletions
diff --git a/modules/forum/forum.module b/modules/forum/forum.module index 3b9aa295f..dbd1944e9 100644 --- a/modules/forum/forum.module +++ b/modules/forum/forum.module @@ -246,7 +246,7 @@ function forum_validate(&$node) { if (db_result(db_query('SELECT COUNT(*) FROM {term_data} WHERE tid = %d AND vid = %d', $term, $vocabulary))) { if (in_array($term, $containers)) { $term = taxonomy_get_term($term); - $error['taxonomy'] = theme('error', t('The item \'%forum\' is only a container for forums. Please select one of the forums below it.', array('%forum' => $term->name))); + form_set_error('taxonomy', t('The item \'%forum\' is only a container for forums. Please select one of the forums below it.', array('%forum' => $term->name))); } else { $node->tid = $term; @@ -254,19 +254,18 @@ function forum_validate(&$node) { } } } - return $error; } /** * Implementation of hook_form(). */ -function forum_form(&$node, &$error) { +function forum_form(&$node) { if (!$node->nid) { // new topic $node->taxonomy[] = arg(3); } - $output = implode('', taxonomy_node_form('forum', $node, $error)); + $output = implode('', taxonomy_node_form('forum', $node)); if ($node->nid) { // if editing, give option to leave shadows |