Gravity Forms : How to transfer HTML like field value

I am trying to dynamically fill in a hidden field of my form with SVG content (a javascript is doing the job).

var outside = $('#teethMapSVG')[0].outerHTML;
console.log("update svg field");
var escapedValue = $('<div/>').text(outside).html();
$("#input_8_118").val(escapedValue);

It works well on client side, but as soon as i save the form, it seems the SVG content disappears and is never saved.
In my object hook:

Read More
add_filter( 'gform_save_field_value_8_118', array($this,'encode_svg_data'), 10, 5 );

i try to save my svg value encoding it :

function encode_svg_data($value, $lead, $field, $form ) {
    log_me("Encoding SVG data of size : ". strlen ( $value ));
    return base64_encode( $value );
}

I suppose my svg tag could be misinterpreted by an underlying protocol, so i would like to encode it into base64 (is it a good idea ?), but i actually never have access to its content, even in different hooks provided by gravity forms before saving.
The field is always empty.

Any idea ?

Thank you very much

Related posts