Preventshop问题与renderList:当我尝试编辑一行时,只有一个字段在获取值,而不是其他字段

问题描述 投票:0回答:1

我正在为公司创建一个prestashop模块。我正在使用助手来做一个干净的工作。问题出在我的renderForm上!当我尝试编辑一行时,只有id_product字段获取值,而不是其他3个字段。所以我想了解为什么?

/* Constructeur */
public function __construct()
{
    $this->bootstrap = true;
    /* Pour aller chercher la table correspondante dans la base */
    $this->table = 'reverdy_aliments';
    $this->className = 'ReverdyPrices';
    $this->deleted = false;

    $this->context = Context::getContext();
    /* Pour ajouter la checkbox à gauche */
    /*$this->bulk_actions = array(
        'delete' => array(
            'text' => $this->l('Delete selected'),
            'confirm' => $this->l('Delete selected items?'),
            'icon' => 'icon-trash'
        )
    );*/

    /* Pour préciser que la clé primaire n'est pas 'id_'.$table */
    $this->identifier = 'id_product';

    parent::__construct();
}

/* Pour ajouter les boutons */
public function renderList()
{
    /* Boutons sur les lignes du tableau */
    $this->addRowAction('edit');

    /* Champs voulus dans le tableau */
    $this->fields_list = array(
        'id_product' => array(
            'title' => $this->l('Produit'),
            'align' => 'center',
            'callback' => 'getAlimentNameById'
        ),
        'departement' => array(
            'title' => $this->l('Département'),
            'align' => 'center'
        ),
        'quantite_kg' => array(
            'title' => $this->l('Quantité'),
            'align' => 'center'
        ),
        'prix_ht' => array(
            'title' => $this->l('Prix H.T.'),
            'align' => 'center'
        )
    );

    return parent::renderList();
}

/* Pour récupérer directement le nom des produits */
public function getAlimentNameById($echo,$row)
{
    $id_product = (int)$row['id_product'];
    if($id_product){
        $produit = new Product($id_product);
        return $produit->name[$this->context->language->id];
    }
    return "";
}

/* Pour le formulaire de modification */
public function renderForm()
{
    if (!($obj = $this->loadObject(true)))
        return;

    $this->fields_form = array(
        'tinymce'=> false,
        'legend' => array(
            'title' => $this->l('Produit'),
            'icon' => 'icon-cogs',
        ),
        'input' => array(
            array(
                'type' => 'text',
                'name' => 'id_product',
                'label' =>  $this->l('Produit'),
                'disabled' => true
            ),
            array(
                'type' => 'text',
                'name' => 'departement',
                'label' =>  $this->l('Département'),
                'disabled' => true
            ),
            array(
                'type' => 'text',
                'name' => 'quantite_kg',
                'label' =>  $this->l('Quantité en kg'),
                'disabled' => true
            ),
            array(
                'type' => 'text',
                'name' => 'prix_ht',
                'label' =>  $this->l('Prix H.T.')
            )
        ),
        'submit' => array(
            'title' => $this->l('Save'),
            'name' => 'submitAdd'.$this->table
        )
    );

    /*$this->fields_value = array('departement' => 'test');
    $this->fields_value['id_employee_default'] = $default_employee;*/

    return parent::renderForm();
}
input module prestashop helper
1个回答
0
投票

[我们已经与Benoit一起看到问题是关于对象模型“ ReverdyPrices”,其中没有通过include或require_once将其包含在模块中。

© www.soinside.com 2019 - 2024. All rights reserved.