Jump to content

How to display a form in front office using a module front controller?

Recommended Posts

Below is the code I have tried to create in my test module


I am getting Fatal errors Fatal error: Call to undefined method testmoduledisplayModuleFrontController::addRowAction() in 

testmoduledisplayModuleFrontController::l() in 


and similar errors ..


How do I solve them ? thank you..


class testmoduledisplayModuleFrontController extends ModuleFrontController


  public function initContent()






  public function __construct()


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

    $this->table = 'games';

    $this->className = 'Games';

    $this->lang = true;



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

    'confirm' => $this->l('Delete selected items?')));

    $this->multishop_context = Shop::CONTEXT_ALL;


    $this->fieldImageSettings = array(

        'name' => 'image',

        'dir' => 'games'



    $this->fields_list = array(

        'id_game' => array(

            'title' => $this->l('ID'),

            'width' => 25




    $this->identifier = 'id_game';




public function renderForm()


    if (!($obj = $this->loadObject(true)))



    $games_list = Activity::getGamesList();     


    $this->fields_form = array(

        'tinymce' => true,          

        'legend' => array(

            'title' => $this->l('Game'),

            'image' => '../img/admin/tab-payment.gif'


        'input' => array(


                  'type' => 'select',

                  'label' => $this->l('Game:'),

                  'desc' => $this->l('Choose a Game'),

                  'name' => 'id_games',

                  'required' => true,

                  'options' => array(

                        'query' => $games_list,

                        'id' => 'id_game',

                        'name' => 'name'




                'type' => 'text',

                'label' => $this->l('Game Title:'),

                'name' => 'name',

                'size' => 64,

                'required' => true,

                'lang' => true,

                'hint' => $this->l('Invalid characters:').' <>;=#{}'



                'type' => 'file',

                'label' => $this->l('Photo:'),

                'name' => 'uploadedfile',

                'id' => 'uploadedfile',

                'display_image' => false,

                'required' => false,

                'desc' => $this->l('Upload your document')





    $this->fields_form['submit'] = array(

        'title' => $this->l('   Save   '),

        'class' => 'button'



    return parent::renderForm();



Share this post

Link to post
Share on other sites

Can anybody help me solve these errors?...I just want to show a form ..using helper form in my front office


Call to undefined method testmoduledisplayModuleFrontController::l()

Edited by JoelWebsites (see edit history)

Share this post

Link to post
Share on other sites


You can't create a form with the Helper in the Front Controller like in the Admin Controller.

You have to do it the old way, with the template and everything.

If you check the ModuleFrontController class and the FrontController class, you can see that their construct is very different from yours.


The Helper is only for BackOffice

And in the FrontController, you can do a function like this :

protected function l($string)
        return Translate::getModuleTranslation('name_module', $string, 'name_front_controller');



And then $this->l()

All the errors you get is because all the functions and properties you are calling don't exist in the FrontController, only in the AdminController.


But maybe in future versions of Prestashop it will be possible with the integration of Symfony

Edited by Steeve (see edit history)

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.

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