0

Comment ajouter des valeurs masquées ou insérer des valeurs dans des champs non exposés à l'utilisateur, tels que date_add et date_upd Classe HelperForm dans PRESTASHOP 1.6.3Ajouter des valeurs masquées ou insérer des valeurs dans des champs qui ne sont pas exposés à l'utilisateur lors de l'utilisation de HelperForm dans PRESTASHOP 1.6.3

J'ai créé un nouveau module et maintenant il y a deux champs dans ma table qui doivent être insérés quand un nouvel ajout se produit et quand une mise à jour est faite par l'utilisateur mais comment le faire quand J'utilise la classe HelperForm Prestashop

Ci-dessous ma forme de script rendre

// This form is populated when add or edit is clicked 
public function renderForm() 
    { 
    $years  = Tools::dateYears(); 
    $months  = Tools::dateMonths(); 
    $days   = Tools::dateDays(); 
    $ticketSeries = Winners::getTicketSeries(); 
    $prdtCategory = Winners::getProductCategory(); 
    $nationality = Winners::getNationality(); 
    $this->fields_form = array(
     'tinymce' => true, 
     'legend' => array(
      'title' => $this->l('Configure your Winner'), 
      'icon' => 'icon-user' 
     ),   
     'input' => array(
      array(
       'type' => 'text', 
       'label' => $this->l('Name'), 
       'name' => 'name', 
       'required' => true, 
       'col' => '4', 
       'hint' => $this->l('Invalid characters:').' 0-9!<>,;?=+()@#"°{}_$%:' 
      ), 
      array(
       'type' => 'text', 
       'label' => $this->l('Ticket No'), 
       'name' => 'ticket_no', 
       'required' => true, 
       'col' => '4', 
       'hint' => $this->l('Invalid characters:').' 0-9!<>,;?=+()@#"°{}_$%:' 
      ), 
      array(
       'type' => 'select', 
       'label' => $this->l('Ticket Series'), 
       'name' => 'series', 
       'required' => true, 
       'options' => array(
        'query' => $ticketSeries, 
        'id' => 'ticket_series_name', 
        'name' => 'ticket_series_name' 
       ), 
       'col' => '4', 
       'hint' => array(
        $this->l('The ticket series of each draw !!.') 
       ) 
      ), 
      array(
       'type' => 'select', 
       'label' => $this->l('Category'), 
       'name' => 'category', 
       'required' => true, 
       'options' => array(
        'query' => $prdtCategory, 
        'id' => 'name', 
        'name' => 'name' 
       ), 
       'col' => '4', 
       'hint' => array(
        $this->l('Product Category.') 
       ) 
      ), 

      array(
       'type' => 'date', 
       'label' => $this->l('Draw Date:'), 
       'name' => 'draw_date', 
       'size' => 10, 
       'required' => true, 
       'desc' => $this->l('The draw date of this series'), 
      ), 
       array(
       'type' => 'select', 
       'label' => $this->l('Nationality'), 
       'name' => 'nationality', 
       'required' => true, 
       'options' => array(
        'query' => $nationality, 
        'id' => 'name', 
        'name' => 'name' 
       ), 
       'col' => '4', 
       'hint' => array(
        $this->l('Nationality the winner Belongs .') 
       ) 
      ), 

      array(
       'type' => 'textarea', 
       'label' => $this->l('Testimonial'), 
       'name' => 'testimonial', 
       'required' => true, 
       'autoload_rte' => true, 
       'rows' => 7, 
       'cols' => 40, 
       'hint' => $this->l('Invalid characters:').' <>;=#{}' 
      ), // add tag 'autoload_rte' => true, 'lang' => true, --> lang i removed 
       // since the editor value did not submit editor     
     ) 
    ); 

    //d(Tools::getIsset('update')); 

    if (Tools::getIsset('add')) 
     $this->fields_form = array_merge(array(
      'input' => array(
      array(
       'type' => 'text', 
       'label' => $this->l('Add Date'), 
       'name' => 'date_add',     
       'col' => '4', 
       'hint' => $this->l('Invalid characters:').' 0-9!&lt;&gt;,;?=+()@#"°{}_$%:' 
      )) 
     )); 
    if (Tools::getIsset('update')) 
     $this->fields_form = array_merge(array(
      'input' => array(
      array(
       'type' => 'text', 
       'label' => $this->l('Update Date'), 
       'name' => 'date_upd',     
       'col' => '4', 
       'hint' => $this->l('Invalid characters:').' 0-9!&lt;&gt;,;? =+()@#"°{}_$%:' 
      )) 
     )); 

    $this->fields_form['submit'] = array(
     'title' => $this->l('Save'), 
    ); 

    $this->addJqueryUI('ui.datepicker'); 
    return parent::renderForm(); 
} 

J'ai essayé quelque chose comme ci-dessous pas encore utilisé

if (Tools::getIsset('add')) 
     $this->fields_form = array_merge(array(
      'input' => array(
      array(
       'type' => 'text', 
       'label' => $this->l('Add Date'), 
       'name' => 'date_add',     
       'col' => '4', 
       'hint' => $this->l('Invalid characters:').' 0-9!&lt;&gt;,;?=+()@#"°{}_$%:' 
      )) 
     )); 
    if (Tools::getIsset('update')) 
     $this->fields_form = array_merge(array(
      'input' => array(
      array(
       'type' => 'text', 
       'label' => $this->l('Update Date'), 
       'name' => 'date_upd',     
       'col' => '4', 
       'hint' => $this->l('Invalid characters:').' 0-9!&lt;&gt;,;? =+()@#"°{}_$%:' 
      )) 
     )); 

Répondre

0

utilisation 'type' => 'hidden' et fournissent la valeur avec, par exemple, 'value' => date("Y-m-d H:i:s")