This forum has moved to a new location and is in read-only mode. Please visit talk.octobercms.com to access the new location.

pwtan14262
pwtan14262

Hi All,

In my Backend plugin, i would like to press a button the and go to a next page. How can i do that in controller? I have already created a button but when i press the button. Its not going any where. The following are snippets of my code.

      <button
                href="<?= Backend::url('pwtan/test/manager/import') ?>"
                class="btn btn-default oc-icon-upload">
                Next
     </button>

import.htm

<?php Block::put('breadcrumb') ?>
        <ul>
          <li><a href="<?= Backend::url('pwtan/test/manager') ?>">
                           Import File
                    </a>
         </li>
           <li><?= e(trans($this->pageTitle)) ?></li>
           </ul>
           <?php Block::endPut() ?>
      <?= Form::open(['class' => 'layout']) ?>
<div class="layout-row">
                <?= $this->importRender() ?>
</div>
<div class="form-buttons">
    <button
        type="submit"
        data-control="popup"
        data-handler="onImportLoadForm"
        data-keyboard="false"
        class="btn btn-primary">
        Import records
    </button>
</div>

<?= Form::close() ?>

Last updated

Crazymodder
Crazymodder

Hi,

The link generation looks right. What exactly is your problem? Does your controller do not respond to your request or is the link not generated?

Regards

Crazymodder

pwtan14262
pwtan14262

Hi Crazymodder,

Thanks for your replay. I think the controller is not responding to my request. When i click on the button, it just refresh the current page. The following is my controller. Thanks.

   <?php namespace Pwtan\Test\Controllers;

   use Backend\Classes\Controller;
   use BackendMenu;
   use Illuminate\Support\Facades\Artisan;
   use Log;
   use DB;
  class Manager extends Controller
 {
        public $implement = ['Backend\Behaviors\ListController',
                              'Backend\Behaviors\FormController'];

        public $listConfig = 'config_list.yaml';
        public $formConfig = 'config_form.yaml';

       public function __construct()
       {
               parent::__construct();
               BackendMenu::setContext('Pwtan.Test', 'Test', 'add import');
       }
  }

Last updated

philipptempel
philipptempel

If you have a <button> it assumes to be inside a form to be processed correctly. Otherwise you won't see much because your browser does not understand what to do (either it will submit the form if there is a form around the button, or it will perform javascript assigned to the button, if there is javascript). So the first thing to consider is this fact. Secondly, you have to properly set up your controller to know it its supposed to show results for the second, third, etc i.e., next page. Your current controller setup does not seem to support any pagination the way you want it to. Maybe you can go from here, if not, let us know.

Last updated

1-4 of 4

You cannot edit posts or make replies: the forum has moved to talk.octobercms.com.