KoolReport's Forum

Official Support Area, Q&As, Discussions, Suggestions and Bug reports.
Forum's Guidelines

PivotMatrix - CSRF Protection Laravel #456

Closed Dimitry opened this topic on on Sep 11, 2018 - 6 comments

Dimitry commented on Sep 11, 2018

Hi :) I have couple of questions.

If you can visit this url: 
 https://beautysalons.site/deptmatrix
I am testing my reports here (sorry for some non English interface).
  1. When I am using PivotMatrix in Laravel it sends post request, but not sending csrf token. Where can I add hidden field with csrf token?
  2. When I am trying to open Pdf in browser it shows me default values not ones that I choose. How can I fix this.
  3. When I move 'client' or any other field on top it loads default values as well.
  4. When I am moving all items 'client', 'date', ... on top it throws exception 'Undefined offset: 0'
Dimitry commented on Sep 11, 2018

I disabled scrf protection for the moment.

David Winterburn commented on Sep 12, 2018

Hi Dimitry,

For Laravel token protection as well as other input parameters, please try adding the scope property to PivotMatrix:

PivotMatrix::create(array(
    "id" => "pivotMatrix1",
    ...
    "scope" =>  array(
		"_token" => csrf_token(),
                "select1" => $this->params["select1"],
                ...
	),
    ...
));

PivotMatrix would submit the scope params together with its internal params so your report could catch them. Let us know if there's any problem with this approach. Thanks!

Dimitry commented on Sep 12, 2018

Thanks David - it works perfect!

If it is possible to help me with other questions it would be very nice :)

Sorry, I understand that I can pass and catch params. Let me play with it, I will revert if I have some problems.

Dimitry commented on Sep 12, 2018

This works fine with PivotMatrix, great :)

I have button for pdf and xls how can I pass this params so I can open pdf filtered?

    <a href="<?= route('deptopenpdf'); ?>" target="_blank" class="btn btn-default">Open PDF</a>
    <a href="<?= route('deptgetpdf'); ?>" class="btn btn-danger">Downoad PDF</a>
    <a href="<?= route('deptgetxls'); ?>" class="btn btn-success">Downoad XLS</a>

And one more question: - When I am moving all items 'client', 'date', ... on top it throws exception 'Undefined offset: 0'

David Winterburn commented on Sep 12, 2018

Hi Dimitry,

To make filter parameters work with exporting, please use <button> for export buttons, put them in a <form> and set their formaction attribute with route. For reference: https://www.w3schools.com/tags/att_button_formaction.asp

Regarding the exception when moving all fields to the top, I will investigate further. Thanks for your feedback!

Dimitry commented on Sep 12, 2018

Thanks for your reply it really helps :)

If you will have any info regarding exception, pls let me know.

Build Your Excellent Data Report

Let KoolReport help you to make great reports. It's free & open-source released under MIT license.

Download KoolReport View demo
solved

Pivot