Mercurial > defr > drupal > core
comparison includes/form.inc @ 11:589fb7c02327 6.5
Drupal 6.5
author | Franck Deroche <webmaster@defr.org> |
---|---|
date | Tue, 23 Dec 2008 14:32:19 +0100 |
parents | acef7ccb09b5 |
children | 8b6c45761e01 |
comparison
equal
deleted
inserted
replaced
10:6f15c9d74937 | 11:589fb7c02327 |
---|---|
1 <?php | 1 <?php |
2 // $Id: form.inc,v 1.265.2.10 2008/08/13 23:59:12 drumm Exp $ | 2 // $Id: form.inc,v 1.265.2.12 2008/09/23 10:51:16 goba Exp $ |
3 | 3 |
4 /** | 4 /** |
5 * @defgroup forms Form builder functions | 5 * @defgroup forms Form builder functions |
6 * @{ | 6 * @{ |
7 * Functions that build an abstract representation of a HTML form. | 7 * Functions that build an abstract representation of a HTML form. |
780 * element is array('foo', 'bar', 'baz') then you may set an error on 'foo' | 780 * element is array('foo', 'bar', 'baz') then you may set an error on 'foo' |
781 * or 'foo][bar][baz'. Setting an error on 'foo' sets an error for every | 781 * or 'foo][bar][baz'. Setting an error on 'foo' sets an error for every |
782 * element where the #parents array starts with 'foo'. | 782 * element where the #parents array starts with 'foo'. |
783 * @param $message | 783 * @param $message |
784 * The error message to present to the user. | 784 * The error message to present to the user. |
785 * @param $reset | |
786 * Reset the form errors static cache. | |
785 * @return | 787 * @return |
786 * Never use the return value of this function, use form_get_errors and | 788 * Never use the return value of this function, use form_get_errors and |
787 * form_get_error instead. | 789 * form_get_error instead. |
788 */ | 790 */ |
789 function form_set_error($name = NULL, $message = '') { | 791 function form_set_error($name = NULL, $message = '', $reset = FALSE) { |
790 static $form = array(); | 792 static $form = array(); |
793 if ($reset) { | |
794 $form = array(); | |
795 } | |
791 if (isset($name) && !isset($form[$name])) { | 796 if (isset($name) && !isset($form[$name])) { |
792 $form[$name] = $message; | 797 $form[$name] = $message; |
793 if ($message) { | 798 if ($message) { |
794 drupal_set_message($message, 'error'); | 799 drupal_set_message($message, 'error'); |
795 } | 800 } |
932 unset($form_state['buttons']); | 937 unset($form_state['buttons']); |
933 } | 938 } |
934 | 939 |
935 // If some callback set #cache, we need to flip a static flag so later it | 940 // If some callback set #cache, we need to flip a static flag so later it |
936 // can be found. | 941 // can be found. |
937 if (isset($form['#cache'])) { | 942 if (!empty($form['#cache'])) { |
938 $cache = $form['#cache']; | 943 $cache = $form['#cache']; |
939 } | 944 } |
940 // We are on the top form, we can copy back #cache if it's set. | 945 // We are on the top form, we can copy back #cache if it's set. |
941 if (isset($form['#type']) && $form['#type'] == 'form' && isset($cache)) { | 946 if (isset($form['#type']) && $form['#type'] == 'form' && isset($cache)) { |
942 $form['#cache'] = TRUE; | 947 $form['#cache'] = TRUE; |