# Multipages form, variables are empty in the backend

**URL:** <https://community.gravityforms.com/t/multipages-form-variables-are-empty-in-the-backend/14371>\
**Category:** Get Help\
**Tags:** custom, gform\_pre\_render, gform\_form\_post\_get\_meta\
**Created:** [February 5, 2023, 9:44pm UTC](https://community.gravityforms.com/t/multipages-form-variables-are-empty-in-the-backend/14371 "2023-02-05T21:44:07Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![dafray1](https://sea2.discourse-cdn.com/flex020/user_avatar/community.gravityforms.com/dafray1/32/5225_2.png) [@dafray1](https://community.gravityforms.com/u/dafray1)\
**Post date:** [February 5, 2023, 9:44pm UTC](https://community.gravityforms.com/t/multipages-form-variables-are-empty-in-the-backend/14371/1 "2023-02-05T21:44:07Z")

</div>

I have a problem, the following code does not work.  
Either the variables are empty or it displays values from the last recorded entry.  
This is a multipage form.

```auto
add_filter( 'gform_form_post_get_meta', 'update_form_field_values' );
 
function update_form_field_values( $form ) {

if ( $form['id'] != 1 ) {
    return $form;
}

$value_to_check = rgar( $form, '6' );
$value_of_field_ip = rgar( $form, '7.3' );
$value_of_field_in = rgar( $form, '7.6' );

if ( $value_to_check == 'Mineur' ) {
  $value_of_field_rp = rgar( $form, '21.3' );
  $value_of_field_rn = rgar( $form, '21.6' );
}

foreach ( $form['fields'] as &$field ) {
  if ( $field->id == 62 ) {
    if($value_to_check == 'Value1') {
      
      $field->label = "$value_of_field_rp $value_of_field_rn, of $value_of_field_ip $value_of_field_in :";
    } else {
      $field->label = " $value_of_field_ip $value_of_field_in :";
    }
  
  break;
  }

}

return $form;
}

```

My previous code who working for frontend user, but not saved in the backend :

```auto

add_filter( 'gform_pre_render', 'update_form_field_values', 10, 2 );

function update_form_field_values( $form, $is_ajax ) {
if ( $form['id'] != 1 ) {
return $form;
}

$entry = RGFormsModel::get_current_lead();
$value_to_check = rgar( $entry, '6' );
$value_of_field_ip = rgar( $entry, '7.3' );
$value_of_field_in = rgar( $entry, '7.6' );

if ( $value_to_check == 'Mineur' ) {
  $value_of_field_rp = rgar( $entry, '21.3' );
  $value_of_field_rn = rgar( $entry, '21.6' );
}

foreach ( $form['fields'] as &$field ) {
  if ( $field->id == 62 ) {
    if($value_to_check == 'Value1') {
      
      $field->label = "$value_of_field_rp $value_of_field_rn, of $value_of_field_ip $value_of_field_in :";
    } else {
      $field->label = "$value_of_field_ip $value_of_field_in :";
    }
  
  break;
  }

}

return $form;
}

```

---

<div class="post-metadata">

**Author:** ![faisalahammad](https://sea2.discourse-cdn.com/flex020/user_avatar/community.gravityforms.com/faisalahammad/32/13948_2.png) [@faisalahammad](https://community.gravityforms.com/u/faisalahammad)\
**Post date:** [February 6, 2023, 1:15pm UTC](https://community.gravityforms.com/t/multipages-form-variables-are-empty-in-the-backend/14371/2 "2023-02-06T13:15:54Z")

</div>

The first code block utilizes the `gform_form_post_get_meta` filter, which runs after the form is loaded and modifies the label of field 62 based on the values of fields 6, 7, and 21. However, these changes will only be visible on the front end and not saved on the backend.

The second code block uses the `gform_pre_render` filter, which runs before the form is displayed to the user. This code retrieves the current entry and alters the label of field 62 based on the values of fields 6, 7, and 21. These changes will be reflected in both the front end and back end.

If the issue is that the values are empty or not up-to-date, it could be due to the way the entry is being retrieved using `RGFormsModel::get_current_lead()`. It is essential to ensure that the correct entry is being retrieved and that the values of the fields are accurate.

---

<div class="post-metadata">

**Author:** ![dafray1](https://sea2.discourse-cdn.com/flex020/user_avatar/community.gravityforms.com/dafray1/32/5225_2.png) [@dafray1](https://community.gravityforms.com/u/dafray1)\
**Post date:** [February 7, 2023, 10:15pm UTC](https://community.gravityforms.com/t/multipages-form-variables-are-empty-in-the-backend/14371/3 "2023-02-07T22:15:48Z")

</div>

The value are retrieved, because in the frontend the values are displayed, but not in the backend… like the label is not saved with values

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex020/uploads/gravityforms1/original/2X/f/fef63f0599c45e0218c30d9f5d7ca8bff9b00189.png) [@system](https://community.gravityforms.com/u/system)\
**Post date:** [March 9, 2023, 10:16pm UTC](https://community.gravityforms.com/t/multipages-form-variables-are-empty-in-the-backend/14371/4 "2023-03-09T22:16:39Z")

</div>

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.
