Page 1 of 1

How to create input field in the report (CustomTemplateHeader)?

Posted: Wed Apr 17, 2024 4:49 pm
by airdriver

Hello, I would like to create an input field in the report (customTemplateHeader) in which the user enters a text that I want to output in the header, later also in the PDF export. Where do I have to place the HTML code?e.g. <input type="text" id="name">.
After the input, the report should then be built with submit.

I don't have this text in the database/table/view.

Basically, I want to fill out a small form and hand it over to the report.

Thank you for help.

These are my first actions with custom templates.

Regards Juergen


Re: How to create input field in the report (CustomTemplateHeader)?

Posted: Wed Apr 17, 2024 10:15 pm
by arbei
  1. If you add <input> tag in CustomTemplateHeader, it will be outputted outside the main table but inside the enclosing <div>, it might not be the position you want (you can try first). You may consider Page_DataRendering which is outputted above the report (no need to use Custom Template ).
  2. There is no form in the report, if you output <input> tag, you need to add the form yourself so you can submit.
  3. You also need add code to handle the form submission yourself (e.g. by Page_Load server event) to get the user input and handle the input as you need.

Re: How to create input field in the report (CustomTemplateHeader)?

Posted: Thu Apr 18, 2024 7:38 pm
by airdriver

This works:

public function pageDataRendering(&$header)
    {
        echo "<form action=...   method=....>";
        echo '<label for="Peilung">Peilung:</label>';
        echo '<input type="text" id="Peilung" name="Peilung">';
        echo '<input type="submit" value="Submit">';
        echo "</form>";
    }

But unfortunately I don't know how to get the variable "Peilung" into my CustomTemplateHeader to display it there.
I can give the form an action and method, but where do I get the $_POST?
Final sorry, but this is my first time working with my own code in phpmaker and I need hints.


Re: How to create input field in the report (CustomTemplateHeader)?

Posted: Thu Apr 18, 2024 9:07 pm
by arbei

arbei wrote:

You also need add code to handle the form submission yourself (e.g. by Page_Load server event) to get the user input and handle the input as you need.


Re: How to create input field in the report (CustomTemplateHeader)?

Posted: Mon Apr 22, 2024 5:18 pm
by airdriver

My solution:

// Page Data Rendering event
function Page_DataRendering(&$header)
{
        echo '<form>';
        echo '<label for="peil">Peilung: </label>';
        echo '<input type="number" id="peil" name="Peilung">';
        echo '<input type="submit" value="Senden">';
        echo "</form>";
}

I have an input field for a number.
In CustomTemplateFooter I get the field value with:

<?php
        $peilung = filter_input(INPUT_GET,'Peilung',FILTER_SANITIZE_NUMBER_INT);
?>

and give it out:

<tr>
<td class="text-center" colspan="9">Istbestandsdifferenz</td>
<td><?php echo $peilung; ?></td>
</tr>