2014-01-24 25 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>