模块 lang 在预处理车间 1.7.6 中不起作用

只是尝试创建一个带有翻译的新的简单模块,但保存过程不起作用。表“ps_myoptions_lang”将使用每个lang_id中的字段进行更新,“ps_myoptions”中不保存任何内容。id_myoptions = 0

http://img2.mukewang.com/631ebd83000191c902340107.jpg

modules/myoptions/controller/admin/AdminOptionsController.php


<?php



require_once(dirname(__FILE__) . './../../classes/Option.php');


class AdminOptionsController extends AdminController

{

    public function __construct(){

        parent::__construct();

        $this->bootstrap = true; // use Bootstrap CSS

        $this->table = 'myoptions'; // SQL table name, will be prefixed with _DB_PREFIX_

        $this->lang = true;

        $this->identifier = 'id_myoptions'; // SQL column to be used as primary key




        $this->className = 'Option'; // PHP class name

        $this->allow_export = true; // allow export in CSV, XLS..



        $this->_defaultOrderBy = 'a.name'; // the table alias is always `a`

        $this->_defaultOrderWay = 'DESC';

        $this->fields_list = [

            'id_myoptions' => ['title' => 'ID','class' => 'fixed-width-xs'],

            'name' => ['title' => 'Name'],

        ];


        $this->addRowAction('edit');

        $this->addRowAction('details');


        $this->fields_form = [

            'legend' => [

                'title' => 'Pasta',

                'icon' => 'icon-list-ul'

            ],

            'input' => [

                ['name'=>'name','type'=>'text', 'lang' => true, 'label'=>'Name','required'=>true],

            ],

            'submit' => [

                'title' => $this->trans('Save', [], 'Admin.Actions'),

            ]

        ];

    }

}


模块/选择/类/选项.php


<?php



class Option extends ObjectModel

{

    public $id;

    public $name;


    public static $definition = [

        'table' => 'myoptions',

        'primary' => 'id_myoptions',

        'multilang' => true,

        'fields' => [

            'name' =>  ['type' => self::TYPE_STRING, 'lang' => true, 'validate' => 'isAnything', 'required'=>true],

        ],

    ];

}

是我做错了什么吗?


翻阅古今
浏览 60回答 1
1回答

至尊宝的传说

我想我发现了问题:&nbsp; &nbsp; $sqlCreate = "CREATE TABLE `" . _DB_PREFIX_ . "myoptions` (&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; `id_myoptions` int(11) unsigned NOT NULL AUTO_INCREMENT,&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; `name` varchar(255) DEFAULT NULL,&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; PRIMARY KEY (`id_myoptions`)&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ) ENGINE=InnoDB DEFAULT CHARSET=latin1;";$sqlCreateLang = "CREATE TABLE `" .&nbsp; _DB_PREFIX_ . "myoptions_lang` (&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; `id_myoptions` int(11) unsigned NOT NULL AUTO_INCREMENT,&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; `id_lang` int(11) NOT NULL,&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; `name` varchar(255) DEFAULT NULL,&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; PRIMARY KEY (`id_myoptions`,`id_lang`)&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ) ENGINE=InnoDB DEFAULT CHARSET=latin1;";Db::getInstance()->execute($sqlCreate) && Db::getInstance()->execute($sqlCreateLang);我在两个表中都有相同的字段。然后我只在Lang表中使用它,它现在似乎可以工作。name
打开App,查看更多内容
随时随地看视频慕课网APP