Jump to content

Module - Backoffice Save Button Tpl Process Issue


Recommended Posts

Hey all,

 

I am trying to process data inputed by a user in a .tpl file.

Located in the module section (backoffice)

I will need help with this since i only know how to do this using PHP only.

Process i need:

  1. User press on the save button (settings.tpl page)
  2. The form gets submitted to mymodulename.php
  3. Public function $postProcces grabs the data send.
  4. Send the data back to settings.tpl with a confirmation that settings are saved.

 

settings.tpl file: (after pressing submit it should send its data to $postProcces)

<!-- $ns_url is the current url in browser -> $_SERVER['REQUEST_URI']; -->
<form action="{$ns_url}" method="post">

<!-- Display data after submit -->
    {if isset($datatest)}  {$datatest}  {/if}

<!-- Data that need to be send to postProcess(); -->
<input type="hidden" name="test" value="test werkt" />

<!-- Save button, post form -->
<button type="submit" value="Submit" name="submit_requestform">Save</button>
</form>

mymodulename.php: (when the save button is clicked, it need to send data to $postProcces)

    public function postProcess()
    {
        // Check if form is submitted
        if (Tools::isSubmit('submit_requestform'))
        {
            // Grab value inside "test"
            $result = Tools::getValue('test');

            // Assign value to datatest variable for use in tpl file
            $this->smarty->assign('datatest', $result);

            // Send data back to settings.tpl
            $output = $this->context->smarty->fetch($this->local_path.'views/templates/admin/settings.tpl');
            return $output.$this->renderForm();
        }
    }
Edited by Crezzur (see edit history)
  • Like 1
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...