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



我正在为我的公司创建一个prestashop模块。我正在使用助手来完成干净的工作。问题出在我的渲染表单上!当我尝试编辑一行时,只有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();
}

我们已经从Benoit中看到,问题在于ObjectModel"ReverdyPrices",其中一没有包含在带有包含或require_once的模块中。

相关内容

最新更新