Hi,

I've made a form that generate a csv file on Form::submitForm. It's working well except I've found this at the end of the file :

<!DOCTYPE html>
<html>
    <head>
        <meta charset="UTF-8" />
        <meta http-equiv="refresh" content="1;url=MySiteUrl" />

        <title>Redirecting to ....</title>
    </head>
    <body>
        Redirecting to <a href="MySiteUrl">MySiteUrl</a>.
    </body>
</html>

How disable that ?

Thx

Comments

Giridhar Mothukuri’s picture

How you are exporting the values?. you can use

decode_entities(strip_tags(''your_values"));

when returning the value

f.schneider’s picture

Hello,

I'm just doing this

    public function submitForm(array &$form, FormStateInterface $form_state)
    {
        $csv = $this->buildCsv($form_state);
        header("Content-Type: text/csv");
        header("Content-Disposition: attachment; filename=" . date('Y-m-d-H-i-s')."_export.csv");
        echo $csv;
   }

Like I said before, something after add html (described in previous post) to the end of the generated csv file. I'd like to know how to prevent this ?