title: Prestashop - Translatable form field fails with HelperForm
body: <p>I'm trying to do a Prestashop module, but when trying to set a translatable form field at the configuration form, it fails.</p>
  
  <p>This is the error I get, through the JS console:</p>
  
  <pre><code>[14:33:39.915] ReferenceError: defaultLanguage is not defined @ http://localhost:8888/js/admin.js:173
  </code></pre>
  
  <p>I think that I have well configurated the languajes in the backoffice, so I'm not sure why is this happening.</p>
  
  <p>This is how I try to create the form:</p>
  
  <pre><code>public function displayForm()
  {
      // Get default Language
      $default_lang = (int)Configuration::get('PS_LANG_DEFAULT');
  
      // Init Fields form array
      $fields_form[0]['form'] = array(
              'legend' =&gt; array(
                      'title' =&gt; $this-&gt;l('Settings'),
              ),
              'input' =&gt; array(
                      array(
                              'type' =&gt; 'text',
                              'label' =&gt; $this-&gt;l('Título de la noticia'),
                              'name' =&gt; 'NOTICIA_TIT',
                              'size' =&gt; 30,
                              'required' =&gt; true,
                              'lang' =&gt; true
                      ),
                      array(
                              'type' =&gt; 'text',
                              'label' =&gt; $this-&gt;l('Imagen de la noticia'),
                              'name' =&gt; 'NOTICIA_IMG',
                              'size' =&gt; 30,
                              'required' =&gt; true,
                              'enabled' =&gt; false
                      ),
                      array( 
                              'type' =&gt; 'file',
                              'label' =&gt; $this-&gt;l('Subir nueva imagen'),
                              'name' =&gt; 'NOTICIA_IMG_FILE',
                              'size' =&gt; 30        
                      ),
                      array(
                              'type' =&gt; 'textarea',
                              'label' =&gt; $this-&gt;l('Texto de la noticia'),
                              'name' =&gt; 'NOTICIA_TXT',
                              'required' =&gt; true,
                              'cols' =&gt; 30,
                              'rows' =&gt; 4,
                              'lang' =&gt; true
                      )
              ),
              'submit' =&gt; array(
                      'title' =&gt; $this-&gt;l('Save'),
                      'class' =&gt; 'button'
              )
      );
  
      $helper = new HelperForm();
  
      // Module, token and currentIndex
      $helper-&gt;module = $this;
      $helper-&gt;name_controller = $this-&gt;name;
      $helper-&gt;token = Tools::getAdminTokenLite('AdminModules');
      $helper-&gt;currentIndex = AdminController::$currentIndex.'&amp;configure='.$this-&gt;name;
  
      // Language
      $helper-&gt;default_form_language = $default_lang;
      $helper-&gt;allow_employee_form_lang = $default_lang;
  
      // Title and toolbar
      $helper-&gt;title = $this-&gt;displayName;
      $helper-&gt;show_toolbar = true;        // false -&gt; remove toolbar
      $helper-&gt;toolbar_scroll = true;      // yes - &gt; Toolbar is always visible on the top of the screen.
      $helper-&gt;submit_action = 'submit'.$this-&gt;name;
      $helper-&gt;toolbar_btn = array(
              'save' =&gt;
              array(
                      'desc' =&gt; $this-&gt;l('Save'),
                      'href' =&gt; AdminController::$currentIndex.'&amp;configure='.$this-&gt;name.'&amp;save'.$this-&gt;name.
                      '&amp;token='.Tools::getAdminTokenLite('AdminModules'),
              ),
              'back' =&gt; array(
                      'href' =&gt; AdminController::$currentIndex.'&amp;token='.Tools::getAdminTokenLite('AdminModules'),
                      'desc' =&gt; $this-&gt;l('Back to list')
              )
      );
  
      // Load current value
      $helper-&gt;fields_value['NOTICIA_TXT'] = Configuration::get('NOTICIA_TXT');
      $helper-&gt;fields_value['NOTICIA_TIT'] = Configuration::get('NOTICIA_TIT');
      $helper-&gt;fields_value['NOTICIA_IMG'] = Configuration::get('NOTICIA_IMG');
  
      return $helper-&gt;generateForm($fields_form);
  }
  </code></pre>
  
  <p>EDIT: I've seen this in the code.</p>
  
  <pre><code>&lt;script type="text/javascript"&gt;
  var module_dir = '/modules/';
      var id_language = 1;
      var languages = new Array();
      var vat_number = 1;
      // Multilang field setup must happen before document is ready so that calls to displayFlags() to avoid
      // precedence conflicts with other document.ready() blocks
              // we need allowEmployeeFormLang var in ajax request
      allowEmployeeFormLang = 1;
      displayFlags(languages, id_language, allowEmployeeFormLang);
  
      $(document).ready(function() {
  
          if ($(".datepicker").length &gt; 0)
              $(".datepicker").datepicker({
                  prevText: '',
                  nextText: '',
                  dateFormat: 'yy-mm-dd'
              });
  
      });
  
  &lt;/script&gt;
  </code></pre>
  
  <p>languajes variable is created as an empty array. However, this is function displayFlags:</p>
  
  <pre><code>function displayFlags(languages, defaultLanguageID, employee_cookie)
  {
  if ($('.translatable'))
  {
      $('.translatable').each(function() {
          if (!$(this).find('.displayed_flag').length &gt; 0) {
              $.each(languages, function(key, language) {
                  if (language['id_lang'] == defaultLanguageID)
                  {
                      defaultLanguage = language;
                      return false;
                  }
              });
              var displayFlags = $('&lt;div&gt;&lt;/div&gt;')
                  .addClass('displayed_flag')
                  .append($('&lt;img&gt;')
                      .addClass('language_current')
                      .addClass('pointer')
                      .attr('src', '../img/l/' + defaultLanguage['id_lang'] + '.jpg')
                      .attr('alt', defaultLanguage['name'])
                      .click(function() {
                          toggleLanguageFlags(this);
                      })
                  );
              var languagesFlags = $('&lt;div&gt;&lt;/div&gt;')
                  .addClass('language_flags')
                  .html('Choose language:&lt;br /&gt;&lt;br /&gt;');
              $.each(languages, function(key, language) {
                  var img = $('&lt;img&gt;')
                      .addClass('pointer')
                      .css('margin', '0 2px')
                      .attr('src', '../img/l/' + language['id_lang'] + '.jpg')
                      .attr('alt', language['name'])
                      .click(function() {
                          changeFormLanguage(language['id_lang'], language['iso_code'], employee_cookie);
                      });
                  languagesFlags.append(img);
              });
              if ($(this).find('p:last-child').hasClass('clear'))
                  $(this).find('p:last-child').before(displayFlags).before(languagesFlags);
              else
                  $(this).append(displayFlags).append(languagesFlags);
          }
      });
  }
  }
  </code></pre>