Title: Setting Field Default Values Dynamically (multiple)
Last modified: February 24, 2021

---

# Setting Field Default Values Dynamically (multiple)

 *  [pparkadmin](https://wordpress.org/support/users/pparkadmin/)
 * (@pparkadmin)
 * [5 years, 3 months ago](https://wordpress.org/support/topic/setting-field-default-values-dynamically-multiple/)
 * So this may be a dumb question, I can see how to setup a function to change a
   field dynamically in a form, but it only seems to work on the first field I set,
   what if I need to change multiple fields in a single form?
 *     ```
       add_filter( 'caldera_forms_render_get_field', function( $field )  {
           if( 'fld_8915153' == $field[ 'ID' ] ){
                           $field[ 'config' ][ 'default' ] = 125;
           }
           return $field;
       }, 10, 2 );
       ```
   
 * This code will only change one field but I need to fill at least 10 fields with
   dynamic data.

Viewing 1 replies (of 1 total)

 *  Thread Starter [pparkadmin](https://wordpress.org/support/users/pparkadmin/)
 * (@pparkadmin)
 * [5 years, 3 months ago](https://wordpress.org/support/topic/setting-field-default-values-dynamically-multiple/#post-14098076)
 * Ok so I have added unique function names now for each of these 2 functions, is
   there a better way than adding a function for each field I want to change?
 *     ```
       add_filter( 'caldera_forms_render_get_field', 'wireless_service_cost_1', 10, 2 );
           function wireless_service_cost_1( $field ) {
               if( 'fld_8915153' == $field[ 'ID' ] ){
                       $field[ 'config' ][ 'default' ] = 125;
               }
               return $field;
           }
   
       add_filter( 'caldera_forms_render_get_field', 'wireless_service_cost_2', 10, 2 );
       function wireless_service_cost_2( $field ) {
           if( 'fld_8185489' == $field[ 'ID' ] ){
                   $field[ 'config' ][ 'default' ] = 25;
           }
           return $field;
       }
       ```
   

Viewing 1 replies (of 1 total)

The topic ‘Setting Field Default Values Dynamically (multiple)’ is closed to new
replies.

 * ![](https://s.w.org/plugins/geopattern-icon/caldera-forms_475846.svg)
 * [Caldera Forms - More Than Contact Forms](https://wordpress.org/plugins/caldera-forms/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/caldera-forms/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/caldera-forms/)
 * [Active Topics](https://wordpress.org/support/plugin/caldera-forms/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/caldera-forms/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/caldera-forms/reviews/)

 * 1 reply
 * 1 participant
 * Last reply from: [pparkadmin](https://wordpress.org/support/users/pparkadmin/)
 * Last activity: [5 years, 3 months ago](https://wordpress.org/support/topic/setting-field-default-values-dynamically-multiple/#post-14098076)
 * Status: not resolved