Jump to content
vignesvaran

renderView() in admin module controller

Recommended Posts

I creates a new custom module with the following code, It displays a list view in back office.

class AdminTestController extends ModuleAdminController
{
public $bootstrap = true;

public function __construct()
{
$this->table = 'test';
$this->className = 'TestData';
$this->lang = false;
$this->deleted = false;
$this->addRowAction('edit');
$this->addRowAction('view');


$this->fields_list = array(
'id_test' => array(
'title' => $this->l('ID'),
'align' => 'center',
'width' => 25
),
'name' => array(
'title' => $this->l('Name'),
'width' => 'auto',
)
);

$this->bulk_actions = array(
'delete' => array(
'text' => $this->l('Delete selected'),
'confirm' => $this->l('Delete selected items?')
)
);

$this->context = Context::getContext();

parent::__construct();
}

public function renderForm()
{
/** @var Test $obj */
if (!($obj = $this->loadObject(true))) {
return;
}

$this->fields_form = array(
'legend' => array(
'title' => $this->l('TEST')
),
'input' => array(
array(
'type' => 'text',
'label' => $this->l('Name'),
'name' => 'name',
'size' => 33,
'required' => true
),
),
'submit' => array(
'title' => $this->l(' Save '),
'class' => 'button pull-right'
)
);

return parent::renderForm();
}

public function renderView()
{
/** @var Test $test */
if (!($test = $this->loadObject())) {
return;
}

$data = Config::getDataForm(Tools::getValue('id_test'));
// var_dump($data);

$this->tpl_view_vars = array(
'id_test' => $data['id_test'],
'name' => $data['name'],
);

return parent::renderView();
}
}

In which I have a renderView() function to show the particular list values in new page.

 

But I get following error on the view page,

 

Fatal error: Class 'Config' not found in /var/www/html/prestashop/modules/test/controllers/admin/AdminTestController.php on line 145

 

 

I am new to prestashop. I am using prestashop 1.6

 

Please help me someone to solve this issue.

 

Thanks in advance.

Share this post


Link to post
Share on other sites

The controller must be in Module/moduleName/controllers/admin folder

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...

Important Information

Cookies ensure the smooth running of our services. Using these, you accept the use of cookies. Learn More