[Bps-public-commit] rt-extension-formtools branch, set-default-value-to-submitted-args-first, created. 0.50-8-g63aa449

Craig Kaiser craig at bestpractical.com
Tue Apr 21 16:24:19 EDT 2020


The branch, set-default-value-to-submitted-args-first has been created
        at  63aa449f4fd863bdb6de398a6e8797b7da5fbdc3 (commit)

- Log -----------------------------------------------------------------
commit 63aa449f4fd863bdb6de398a6e8797b7da5fbdc3
Author: Craig Kaiser <craig at bestpractical.com>
Date:   Fri Apr 17 13:36:50 2020 -0400

    Have the submitted args values have the highest priority for default value
    
    This allows for pages that redirect to themselves on error to populate
    inputs with the submittted values from the previous page.

diff --git a/html/FormTools/Field b/html/FormTools/Field
index 06608b7..73954e4 100644
--- a/html/FormTools/Field
+++ b/html/FormTools/Field
@@ -78,14 +78,12 @@ if ( RT::Extension::FormTools::is_core_field($name) ) {
 }
 
 
-unless ( $default ) {
-    my $request_args = $m->request_args();
-    if ( $field_type eq 'core' && $request_args->{$name} ) {
-        $default = $request_args->{$name};
-    } elsif ( $field_type eq 'custom' &&  $cf->Id ) {
-        $default = ($request_args->{ $input_name } || 
-                    $request_args->{ $input_name .'s' } );
-    }
+my $request_args = $m->request_args();
+if ( $field_type eq 'core' && exists $request_args->{$name} ) {
+    $default = $request_args->{$name};
+} elsif ( $field_type eq 'custom' && $cf->Id && exists $request_args->{ $input_name } ) {
+    $default = ($request_args->{ $input_name } ||
+                $request_args->{ $input_name .'s' } );
 }
 
 $default = '' unless defined $default;

-----------------------------------------------------------------------


More information about the Bps-public-commit mailing list