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

Craig Kaiser craig at bestpractical.com
Wed Apr 22 11:54:50 EDT 2020


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

- Log -----------------------------------------------------------------
commit 8016b46f45b7c69bebbd3344665828d514c0ae04
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..3f290fb 100644
--- a/html/FormTools/Field
+++ b/html/FormTools/Field
@@ -78,14 +78,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 } || $request_args->{ $input_name .'s' } ) ) {
+    $default = ($request_args->{ $input_name } ||
+                $request_args->{ $input_name .'s' } );
 }
 
 $default = '' unless defined $default;

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


More information about the Bps-public-commit mailing list