@@ -1682,7 +1682,10 @@ function form_clear_error() {
1682
1682
}
1683
1683
1684
1684
/**
1685
- * Returns an associative array of all errors.
1685
+ * Returns an associative array of all errors if any.
1686
+ *
1687
+ * @return array|null
1688
+ * The form errors if any, NULL otherwise.
1686
1689
*/
1687
1690
function form_get_errors () {
1688
1691
$ form = form_set_error ();
@@ -2307,8 +2310,8 @@ function form_state_values_clean(&$form_state) {
2307
2310
* A keyed array containing the current state of the form.
2308
2311
*
2309
2312
* @return
2310
- * The data that will appear in the $form_state['values'] collection
2311
- * for this element. Return nothing to use the default.
2313
+ * The data that will appear in $form_state['values'] for this element, or
2314
+ * nothing to use the default.
2312
2315
*/
2313
2316
function form_type_image_button_value ($ form , $ input , $ form_state ) {
2314
2317
if ($ input !== FALSE ) {
@@ -2353,8 +2356,8 @@ function form_type_image_button_value($form, $input, $form_state) {
2353
2356
* the element's default value should be returned.
2354
2357
*
2355
2358
* @return
2356
- * The data that will appear in the $element_state ['values'] collection
2357
- * for this element. Return nothing to use the default.
2359
+ * The data that will appear in $form_state ['values'] for this element, or
2360
+ * nothing to use the default.
2358
2361
*/
2359
2362
function form_type_checkbox_value ($ element , $ input = FALSE ) {
2360
2363
if ($ input === FALSE ) {
@@ -2394,8 +2397,8 @@ function form_type_checkbox_value($element, $input = FALSE) {
2394
2397
* the element's default value should be returned.
2395
2398
*
2396
2399
* @return
2397
- * The data that will appear in the $element_state ['values'] collection
2398
- * for this element. Return nothing to use the default.
2400
+ * The data that will appear in $form_state ['values'] for this element, or
2401
+ * nothing to use the default.
2399
2402
*/
2400
2403
function form_type_checkboxes_value ($ element , $ input = FALSE ) {
2401
2404
if ($ input === FALSE ) {
@@ -2435,8 +2438,8 @@ function form_type_checkboxes_value($element, $input = FALSE) {
2435
2438
* the element's default value should be returned.
2436
2439
*
2437
2440
* @return
2438
- * The data that will appear in the $element_state ['values'] collection
2439
- * for this element. Return nothing to use the default.
2441
+ * The data that will appear in $form_state ['values'] for this element, or
2442
+ * nothing to use the default.
2440
2443
*/
2441
2444
function form_type_tableselect_value ($ element , $ input = FALSE ) {
2442
2445
// If $element['#multiple'] == FALSE, then radio buttons are displayed and
@@ -2471,8 +2474,8 @@ function form_type_tableselect_value($element, $input = FALSE) {
2471
2474
* element's default value is returned. Defaults to FALSE.
2472
2475
*
2473
2476
* @return
2474
- * The data that will appear in the $element_state ['values'] collection for
2475
- * this element .
2477
+ * The data that will appear in $form_state ['values'] for this element, or
2478
+ * nothing to use the default .
2476
2479
*/
2477
2480
function form_type_radios_value (&$ element , $ input = FALSE ) {
2478
2481
if ($ input !== FALSE ) {
@@ -2510,8 +2513,8 @@ function form_type_radios_value(&$element, $input = FALSE) {
2510
2513
* the element's default value should be returned.
2511
2514
*
2512
2515
* @return
2513
- * The data that will appear in the $element_state ['values'] collection
2514
- * for this element. Return nothing to use the default.
2516
+ * The data that will appear in $form_state ['values'] for this element, or
2517
+ * nothing to use the default.
2515
2518
*/
2516
2519
function form_type_password_confirm_value ($ element , $ input = FALSE ) {
2517
2520
if ($ input === FALSE ) {
@@ -2541,8 +2544,8 @@ function form_type_password_confirm_value($element, $input = FALSE) {
2541
2544
* the element's default value should be returned.
2542
2545
*
2543
2546
* @return
2544
- * The data that will appear in the $element_state ['values'] collection
2545
- * for this element. Return nothing to use the default.
2547
+ * The data that will appear in $form_state ['values'] for this element, or
2548
+ * nothing to use the default.
2546
2549
*/
2547
2550
function form_type_select_value ($ element , $ input = FALSE ) {
2548
2551
if ($ input !== FALSE ) {
@@ -2578,12 +2581,12 @@ function form_type_select_value($element, $input = FALSE) {
2578
2581
* @param array $element
2579
2582
* The form element whose value is being populated.
2580
2583
* @param mixed $input
2581
- * The incoming input to populate the form element. If this is FALSE,
2582
- * the element's default value should be returned.
2584
+ * The incoming input to populate the form element. If this is FALSE, the
2585
+ * element's default value should be returned.
2583
2586
*
2584
2587
* @return string
2585
- * The data that will appear in the $element_state ['values'] collection
2586
- * for this element. Return nothing to use the default.
2588
+ * The data that will appear in $form_state ['values'] for this element, or
2589
+ * nothing to use the default.
2587
2590
*/
2588
2591
function form_type_textarea_value ($ element , $ input = FALSE ) {
2589
2592
if ($ input !== FALSE && $ input !== NULL ) {
@@ -2603,8 +2606,8 @@ function form_type_textarea_value($element, $input = FALSE) {
2603
2606
* the element's default value should be returned.
2604
2607
*
2605
2608
* @return
2606
- * The data that will appear in the $element_state ['values'] collection
2607
- * for this element. Return nothing to use the default.
2609
+ * The data that will appear in $form_state ['values'] for this element, or
2610
+ * nothing to use the default.
2608
2611
*/
2609
2612
function form_type_textfield_value ($ element , $ input = FALSE ) {
2610
2613
if ($ input !== FALSE && $ input !== NULL ) {
@@ -2627,8 +2630,8 @@ function form_type_textfield_value($element, $input = FALSE) {
2627
2630
* the element's default value should be returned.
2628
2631
*
2629
2632
* @return
2630
- * The data that will appear in the $element_state ['values'] collection
2631
- * for this element. Return nothing to use the default.
2633
+ * The data that will appear in $form_state ['values'] for this element, or
2634
+ * nothing to use the default.
2632
2635
*/
2633
2636
function form_type_token_value ($ element , $ input = FALSE ) {
2634
2637
if ($ input !== FALSE ) {
@@ -3377,6 +3380,30 @@ function form_process_actions($element, &$form_state) {
3377
3380
return $ element ;
3378
3381
}
3379
3382
3383
+ /**
3384
+ * Processes a form button element.
3385
+ *
3386
+ * @param $element
3387
+ * An associative array containing the properties and children of the
3388
+ * form button.
3389
+ * @param $form_state
3390
+ * The $form_state array for the form this element belongs to.
3391
+ *
3392
+ * @return
3393
+ * The processed element.
3394
+ */
3395
+ function form_process_button ($ element , &$ form_state ) {
3396
+ // We normally want to add drupal.form-single-submit so that the double submit
3397
+ // protection can be added to the site, however, with the addition of
3398
+ // javascript_always_use_jquery, this would make most pages with a login
3399
+ // block or a search form have jquery always added, changing what people who
3400
+ // set the javascript_always_use_jquery variable to FALSE would have expected.
3401
+ if (variable_get ('javascript_always_use_jquery ' , TRUE ) && variable_get ('javascript_use_double_submit_protection ' , TRUE )) {
3402
+ $ element ['#attached ' ]['library ' ][] = array ('system ' , 'drupal.form-single-submit ' );
3403
+ }
3404
+ return $ element ;
3405
+ }
3406
+
3380
3407
/**
3381
3408
* Processes a container element.
3382
3409
*
0 commit comments