Jump to content

[SOLVED] File upload Helper


gr4devel

Recommended Posts

Hi community.

 

I'm wondering why I get the result of the attached image with the following code:

$default_lang = (int)Configuration::get('PS_LANG_DEFAULT');
    $fields_form[0]['form'] = array(
      'legend' => array(
        'title' => $this->l('Import combinations'),
        'image' => '../img/admin/cog.gif'
      ),
      'input' => array(
        array(
          'type' => 'file',
          'name' => 'my-name',
          'multiple' => true,
          'label' => $this->l('Choose combinations file'),
          'desc' => $this->l('Terms display on the top of the form.'),
          'lang' => true,
          'id' => 'my-name'
        )
      ),
      'submit' => array(
        'title' => $this->l('Import'),
        'class' => 'button'
      )
    );

    $helper = new HelperForm();
    $helper->module = $this;
    $helper->name_controller = $this->name;
    $helper->token = Tools::getAdminTokenLite('AdminModules');
    $helper->currentIndex = AdminController::$currentIndex.'&configure='.$this->name;
    $helper->languages = Language::getLanguages();
    $helper->default_form_language = $default_lang;
    $helper->allow_employee_form_lang = $default_lang;
    $helper->title = $this->displayName;
    $helper->show_toolbar = true;
    $helper->toolbar_scroll = true;
    $helper->submit_action = 'submit'.$this->name;
    $helper->toolbar_btn = array(
      'save' => array(
        'desc' => $this->l('Save'),
        'href' => AdminController::$currentIndex.'&configure='.$this->name.'&save'.$this->name.
        '&token='.Tools::getAdminTokenLite('AdminModules'),
      ),
      'back' => array(
        'href' => AdminController::$currentIndex.'&token='.Tools::getAdminTokenLite('AdminModules'),
        'desc' => $this->l('Back to list')
      )
    );
    // $helper->fields_value['BETTERPRICE_EMAIL'] = Configuration::get('BETTERPRICE_EMAIL');

    return $helper->generateForm($fields_form);

post-486986-0-92221700-1410207613_thumb.png

Edited by gr4devel (see edit history)
Link to comment
Share on other sites

If you check inside the simple.tpl (admin/themes/default/template/helpers/uploader/simple.tpl) you can see that a smarty variable $multiple is actually used...

 

Anyway I can't find any official DOC about the file input type and so I'm currently working blindly...

 

Sincerely I don't want to try to figure it out how the field works by manually checking the view and the controller code...

 

A framework like PS (at its version) should have a proper documentation about its functionality...

Link to comment
Share on other sites

Ok the problem here was related to the fact that the module I was creating didn't was "bootstraped".

 

Take a look here: http://doc.prestashop.com/display/PS16/Making+your+module+work+with+Bootstrap

 

TL;DR: just add 

$this->bootstrap = true;

to your module constructor and the problem should be fixed.

Edited by gr4devel (see edit history)
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...