Issue with updating form object for use with update_form

I am trying to update the values of some form fields in the backend. Doing this using the get_form object and the update_form function

However I am just not quite getting there. The form values are not updated. I get an error of

Notice : Indirect modification of overloaded element of GF_Field_Select has no effect in functions.php** on line 845

which is this line


foreach ( $field['choices'] as $key => &$choice )
$form_id = '6';
$form = GFAPI::get_form( $form_id );

foreach ( $form['fields'] as $key => &$field )
{
    if (isset( $field['id']) && $field['id'] == 47 )
    {
        foreach ( $field['choices'] as $key => &$choice )
        {
            if (isset($choice['value']) && $choice['value'] == 1)
            {
                $choice['text'] = 'test';
                $choice['price'] = '99';

                echo '<pre>'.print_r( $choice['text']).'</pre>';
                echo '<pre>'.print_r( $choice['price']).'</pre>';
            }
        }
    }
}

echo '<pre>'.print_r( $form['fields'][8]['choices'][0]['text'] ).'</pre>';

$result = GFAPI::update_form( $form, $form_id );
return $result;

Within the nested foreach loop my modified value is echoed, but outside of the nested foreach loop I still get the original array values. Can’t figure what mistake I am making.

Cheers