2014-01-24 45 views
0

我用的Prestashop 1.4,並希望該文件authentication.tpl我添加corrcet HTML輸入字段中添加新的領域,在文件/classes/Customer.php,不需要場我沒有將它添加到$ fieldsRequired的變量$ fieldsSize我添加了它,大小爲132個字符,並在$ fieldsValidate字符串驗證。的Prestashop添加新regisration場錯誤

這是可以的。但該字段未插入到數據庫中(字段已插入#_customer表中)。

在功能getFields()我加入這個領域,如果我加入這個領域,我得到錯誤信息,域代碼是:

$fields['amazonresellerid'] = pSQL($this->amazonresellerid); 

而且有問題,如果我加入這個,然後我ger提交錯誤消息:「創建帳戶時發生錯誤。」,所有字段名稱都完全寫入,無法理解,我在這裏做了什麼錯誤?

回答

0

這裏是一個超負荷的prestashop 1.4添加一個字段的示例:

添加字段到數據庫:

ALTER TABLE `ps_customer` ADD `amazonresellerid` VARCHAR(12) NOT NULL AFTER `date_upd` 

創建Customer.php IN /覆寫/班/並把這個代碼:

<?php 

class Customer extends CustomerCore 
{ 
    public $amazonresellerid; 

    protected $fieldsValidate = array(
     'secure_key' => 'isMd5', 
     'lastname' => 'isName', 
     'firstname' => 'isName', 
     'email' => 'isEmail', 
     'passwd' => 'isPasswd', 
     'id_gender' => 'isUnsignedId', 
     'birthday' => 'isBirthDate', 
     'newsletter' => 'isBool', 
     'optin' => 'isBool', 
     'active' => 'isBool', 
     'note' => 'isCleanHtml', 
     'is_guest' => 'isBool', 
     'amazonresellerid' => 'isString' 
    ); 

    public function getFields() 
    { 
     $fields = parent::getFields(); 
     $fields['amazonresellerid'] = pSQL($this->amazonresellerid); 
     return $fields; 
    } 

} 

?> 

而且在authentication.tpl添加輸入:

<p class="text"> 
    <label for="amazonresellerid">{l s='Amazon reseller id'}</label> 
    <input type="text" class="text" name="amazonresellerid" id="amazonresellerid" value="{if isset($smarty.post.amazonresellerid)}{$smarty.post.amazonresellerid}{/if}" /> 
</p>