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

Craig Kaiser craig at bestpractical.com
Thu Apr 23 11:26:40 EDT 2020


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

- Log -----------------------------------------------------------------
commit a13c330e847b7df576aef467c85a37dd76e89f8d
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..8683750 100644
--- a/html/FormTools/Field
+++ b/html/FormTools/Field
@@ -77,15 +77,13 @@ 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