title: Prestashop - edit customer Id from backend
body: <p>Hello everybody I've made an override of Prestashop Customers object form to edit the customer's id from backend. I rendere all the fields with no problem but when I push sabe button it gives me error... I will paste my code below.</p>
  
  <pre><code>&lt;?php
      Class AdminCustomersController extends AdminCustomersControllerCore{
          public function renderForm(){
              /** @var Customer $obj */
              if (!($obj = $this-&gt;loadObject(true))) {return;}
              $genders = Gender::getGenders();
              $list_genders = array();
              foreach ($genders as $key =&gt; $gender) {
                  /** @var Gender $gender */
                  $list_genders[$key]['id'] = 'gender_'.$gender-&gt;id;
                  $list_genders[$key]['value'] = $gender-&gt;id;
                  $list_genders[$key]['label'] = $gender-&gt;name;
              }
              $years = Tools::dateYears();
              $months = Tools::dateMonths();
              $days = Tools::dateDays();
              $groups = Group::getGroups($this-&gt;default_form_language, true);
              $this-&gt;fields_form = array(
                  'legend' =&gt; array(
                      'title' =&gt; $this-&gt;l('Customer'),
                      'icon' =&gt; 'icon-user'
                  ),
                  'input' =&gt; array(
                      array(
                          'type' =&gt; 'text', // id_customer field to edit 
                          'label' =&gt; $this-&gt;l('Codice cliente'),
                          'name' =&gt; 'id_customer',
                          'size' =&gt; 64,
                          'col' =&gt; '4'
                      ),
                      array(
                          'type' =&gt; 'radio',
                          'label' =&gt; $this-&gt;l('Social title'),
                          'name' =&gt; 'id_gender',
                          'required' =&gt; false,
                          'class' =&gt; 't',
                          'values' =&gt; $list_genders
                      ),
                      array(
                          'type' =&gt; 'text',
                          'label' =&gt; $this-&gt;l('First name'),
                          'name' =&gt; 'firstname',
                          'required' =&gt; true,
                          'col' =&gt; '4',
                          'hint' =&gt; $this-&gt;l('Invalid characters:').' 0-9!&amp;lt;&amp;gt;,;?=+()@#"°{}_$%:'
                      ),
                      array(
                          'type' =&gt; 'text',
                          'label' =&gt; $this-&gt;l('Last name'),
                          'name' =&gt; 'lastname',
                          'required' =&gt; true,
                          'col' =&gt; '4',
                          'hint' =&gt; $this-&gt;l('Invalid characters:').' 0-9!&amp;lt;&amp;gt;,;?=+()@#"°{}_$%:'
                      ),
                      array(
                          'type' =&gt; 'text',
                          'label' =&gt; $this-&gt;l('Codice cliente Target:'),
                          'name' =&gt; 'codice_target',
                          'size' =&gt; 64,
                          'col' =&gt; '4'
                      ),
                      array(
                          'type' =&gt; 'text',
                          'label' =&gt; $this-&gt;l('Company'),
                          'name' =&gt; 'company',
                          'required' =&gt; true,
                          'col' =&gt; '4',
                          'hint' =&gt; $this-&gt;l('Invalid characters:').' 0-9!&amp;lt;&amp;gt;,;?=+()@#"°{}_$%:'
                      ),
                      array(
                          'type' =&gt; 'text',
                          'label' =&gt; $this-&gt;l('P.iva'),
                          'name' =&gt; 'vat_number',
                          'required' =&gt; true,
                          'col' =&gt; '4',
                          'hint' =&gt; $this-&gt;l('Invalid characters:').' 0-9!&amp;lt;&amp;gt;,;?=+()@#"°{}_$%:'
                      ),
                      array(
                          'type' =&gt; 'text',
                          'prefix' =&gt; '&lt;i class="icon-envelope-o"&gt;&lt;/i&gt;',
                          'label' =&gt; $this-&gt;l('Email address'),
                          'name' =&gt; 'email',
                          'col' =&gt; '4',
                          'required' =&gt; true,
                          'autocomplete' =&gt; false
                      ),
                      array(
                          'type' =&gt; 'password',
                          'label' =&gt; $this-&gt;l('Password'),
                          'name' =&gt; 'passwd',
                          'required' =&gt; ($obj-&gt;id ? false : true),
                          'col' =&gt; '4',
                          'hint' =&gt; ($obj-&gt;id ? $this-&gt;l('Leave this field blank if there\'s no change.') :
                              sprintf($this-&gt;l('Password should be at least %s characters long.'), Validate::PASSWORD_LENGTH))
                      ),
                      /*array(
                          'type' =&gt; 'birthday',
                          'label' =&gt; $this-&gt;l('Birthday'),
                          'name' =&gt; 'birthday',
                          'options' =&gt; array(
                              'days' =&gt; $days,
                              'months' =&gt; $months,
                              'years' =&gt; $years
                          )
                      ),*/
                      array(
                          'type' =&gt; 'switch',
                          'label' =&gt; $this-&gt;l('Enabled'),
                          'name' =&gt; 'active',
                          'required' =&gt; false,
                          'class' =&gt; 't',
                          'is_bool' =&gt; true,
                          'values' =&gt; array(
                              array(
                                  'id' =&gt; 'active_on',
                                  'value' =&gt; 1,
                                  'label' =&gt; $this-&gt;l('Enabled')
                              ),
                              array(
                                  'id' =&gt; 'active_off',
                                  'value' =&gt; 0,
                                  'label' =&gt; $this-&gt;l('Disabled')
                              )
                          ),
                          'hint' =&gt; $this-&gt;l('Enable or disable customer login.')
                      ),
                      array(
                          'type' =&gt; 'switch',
                          'label' =&gt; $this-&gt;l('Newsletter'),
                          'name' =&gt; 'newsletter',
                          'required' =&gt; false,
                          'class' =&gt; 't',
                          'is_bool' =&gt; true,
                          'values' =&gt; array(
                              array(
                                  'id' =&gt; 'newsletter_on',
                                  'value' =&gt; 1,
                                  'label' =&gt; $this-&gt;l('Enabled')
                              ),
                              array(
                                  'id' =&gt; 'newsletter_off',
                                  'value' =&gt; 0,
                                  'label' =&gt; $this-&gt;l('Disabled')
                              )
                          ),
                          'disabled' =&gt;  (bool)!Configuration::get('PS_CUSTOMER_NWSL'),
                          'hint' =&gt; $this-&gt;l('This customer will receive your newsletter via email.')
                      ),
                      array(
                          'type' =&gt; 'switch',
                          'label' =&gt; $this-&gt;l('Opt-in'),
                          'name' =&gt; 'optin',
                          'required' =&gt; false,
                          'class' =&gt; 't',
                          'is_bool' =&gt; true,
                          'values' =&gt; array(
                              array(
                                  'id' =&gt; 'optin_on',
                                  'value' =&gt; 1,
                                  'label' =&gt; $this-&gt;l('Enabled')
                              ),
                              array(
                                  'id' =&gt; 'optin_off',
                                  'value' =&gt; 0,
                                  'label' =&gt; $this-&gt;l('Disabled')
                              )
                          ),
                          'disabled' =&gt;  (bool)!Configuration::get('PS_CUSTOMER_OPTIN'),
                          'hint' =&gt; $this-&gt;l('This customer will receive your ads via email.')
                      ),
                  )
              );
              // if we add a customer via fancybox (ajax), it's a customer and he doesn't need to be added to the visitor and guest groups
              if(Tools::isSubmit('addcustomer') &amp;&amp; Tools::isSubmit('submitFormAjax')){
                  $visitor_group = Configuration::get('PS_UNIDENTIFIED_GROUP');
                  $guest_group = Configuration::get('PS_GUEST_GROUP');
                  foreach ($groups as $key =&gt; $g) {
                      if (in_array($g['id_group'], array($visitor_group, $guest_group))) {
                          unset($groups[$key]);
                      }
                  }
              }
              $this-&gt;fields_form['input'] = array_merge(
                  $this-&gt;fields_form['input'],
                  array(
                      array(
                          'type' =&gt; 'group',
                          'label' =&gt; $this-&gt;l('Group access'),
                          'name' =&gt; 'groupBox',
                          'values' =&gt; $groups,
                          'required' =&gt; true,
                          'col' =&gt; '6',
                          'hint' =&gt; $this-&gt;l('Select all the groups that you would like to apply to this customer.')
                      ),
                      array(
                          'type' =&gt; 'select',
                          'label' =&gt; $this-&gt;l('Default customer group'),
                          'name' =&gt; 'id_default_group',
                          'options' =&gt; array(
                              'query' =&gt; $groups,
                              'id' =&gt; 'id_group',
                              'name' =&gt; 'name'
                          ),
                          'col' =&gt; '4',
                          'hint' =&gt; array(
                              $this-&gt;l('This group will be the user\'s default group.'),
                              $this-&gt;l('Only the discount for the selected group will be applied to this customer.')
                          )
                      )
                  )
              );
              // if customer is a guest customer, password hasn't to be there
              if ($obj-&gt;id &amp;&amp; ($obj-&gt;is_guest &amp;&amp; $obj-&gt;id_default_group == Configuration::get('PS_GUEST_GROUP'))) {
                  foreach ($this-&gt;fields_form['input'] as $k =&gt; $field) {
                      if ($field['type'] == 'password') {
                          array_splice($this-&gt;fields_form['input'], $k, 1);
                      }
                  }
              }
              if(Configuration::get('PS_B2B_ENABLE')) {
                  $risks = Risk::getRisks();
                  $list_risks = array();
                  foreach ($risks as $key =&gt; $risk) {
                      /** @var Risk $risk */
                      $list_risks[$key]['id_risk'] = (int)$risk-&gt;id;
                      $list_risks[$key]['name'] = $risk-&gt;name;
                  }
                  $this-&gt;fields_form['input'][] = array(
                      'type' =&gt; 'text',
                      'label' =&gt; $this-&gt;l('Company'),
                      'name' =&gt; 'company'
                  );
                  $this-&gt;fields_form['input'][] = array(
                      'type' =&gt; 'text',
                      'label' =&gt; $this-&gt;l('SIRET'),
                      'name' =&gt; 'siret'
                  );
                  $this-&gt;fields_form['input'][] = array(
                      'type' =&gt; 'text',
                      'label' =&gt; $this-&gt;l('APE'),
                      'name' =&gt; 'ape'
                  );
                  $this-&gt;fields_form['input'][] = array(
                      'type' =&gt; 'text',
                      'label' =&gt; $this-&gt;l('Website'),
                      'name' =&gt; 'website'
                  );
                  $this-&gt;fields_form['input'][] = array(
                      'type' =&gt; 'text',
                      'label' =&gt; $this-&gt;l('Allowed outstanding amount'),
                      'name' =&gt; 'outstanding_allow_amount',
                      'hint' =&gt; $this-&gt;l('Valid characters:').' 0-9',
                      'suffix' =&gt; $this-&gt;context-&gt;currency-&gt;sign
                  );
                  $this-&gt;fields_form['input'][] = array(
                      'type' =&gt; 'text',
                      'label' =&gt; $this-&gt;l('Maximum number of payment days'),
                      'name' =&gt; 'max_payment_days',
                      'hint' =&gt; $this-&gt;l('Valid characters:').' 0-9'
                  );
                  $this-&gt;fields_form['input'][] = array(
                      'type' =&gt; 'select',
                      'label' =&gt; $this-&gt;l('Risk rating'),
                      'name' =&gt; 'id_risk',
                      'required' =&gt; false,
                      'class' =&gt; 't',
                      'options' =&gt; array(
                          'query' =&gt; $list_risks,
                          'id' =&gt; 'id_risk',
                          'name' =&gt; 'name'
                      ),
                  );
              }
              $this-&gt;fields_form['submit'] = array(
                  'title' =&gt; $this-&gt;l('Save'),
              );
              $birthday = explode('-', $this-&gt;getFieldValue($obj, 'birthday'));
              $this-&gt;fields_value = array(
                  'years' =&gt; $this-&gt;getFieldValue($obj, 'birthday') ? $birthday[0] : 0,
                  'months' =&gt; $this-&gt;getFieldValue($obj, 'birthday') ? $birthday[1] : 0,
                  'days' =&gt; $this-&gt;getFieldValue($obj, 'birthday') ? $birthday[2] : 0,
              );
              // Added values of object Group
              if (!Validate::isUnsignedId($obj-&gt;id)) {
                  $customer_groups = array();
              }
              else {
                  $customer_groups = $obj-&gt;getGroups();
              }
              $customer_groups_ids = array();
              if (is_array($customer_groups)) {
                  foreach ($customer_groups as $customer_group) {
                      $customer_groups_ids[] = $customer_group;
                  }
              }
              // if empty $carrier_groups_ids : object creation : we set the default groups
              if (empty($customer_groups_ids)) {
                  $preselected = array(
                      Configuration::get('PS_UNIDENTIFIED_GROUP'),
                      Configuration::get('PS_GUEST_GROUP'),
                      Configuration::get('PS_CUSTOMER_GROUP')
                  );
                  $customer_groups_ids = array_merge($customer_groups_ids, $preselected);
              }
              foreach ($groups as $group) {
                  $this-&gt;fields_value['groupBox_'.$group['id_group']] = Tools::getValue('groupBox_'.$group['id_group'], in_array($group['id_group'], $customer_groups_ids));
              }
              return AdminController::renderForm();
          }
      }
  ?&gt;
  </code></pre>
  
  <p>Many thanks</p>