Question

I'm looking to add a button that executes my own custom code.

I've successfully created the page, along with a button but I can't for the life of me get it todo anything. I've stripped it back down to basics, where I just display the page with the layout form etc.

Please see my code below, I wondered if anyone would be able to help me/point me in the right direction.

Thank you in advance.

My Controller

    <?php

namespace Ozark\Maxoptra\Controller\Adminhtml\ExportEmail;


use Laminas\Form\Element\Button;
use Magento\Backend\App\Action\Context;
use Magento\Framework\View\Element\UiComponent\Control\ButtonProviderInterface;
use Magento\Framework\View\ResultPageFactory;

class Index extends \Magento\Backend\App\Action
{
    private $resultPageFactory;

    public function __construct(
        \Magento\Backend\App\Action\Context $context,
        \Magento\Framework\View\Result\PageFactory $resultPageFactory
    ) {
        parent::__construct($context);
        $this->resultPageFactory = $resultPageFactory;
    }
    public function execute()
    {
        $resultPage = $this->resultPageFactory->create(); // this crete an empty page
        return $resultPage;// this show page
    }

}

Template

  <h2 class="export main">Test info@xxxxxxx.co.uk</h2>
<br>
<form class="export button">
    <input type="submit" value="Run Export" name="runExport" />
</form>
Was it helpful?

Solution

in magento 2.x ui components are used for adding the classic orange buttons at the top (saving, modifying, deleting etc.). Are you interested in such a thing or a normal button?

Cheers

Licensed under: CC-BY-SA with attribution
Not affiliated with magento.stackexchange
scroll top