10/10/2018, 11:38
[Codeigniter]tên trong giỏ hàng
Trong giỏ hàng khi đặt tên như
nhưng khi đặt tên có kí tự đặc biệt hoặc tiếng Việt là không được.
Có cách nào khắc phục được không ạ
Code:
$data=array( 'id' => 'ttt', 'name' => 'Cisco' ); $this->cart->insert($data);
Code:
$data=array( 'id' => 'ttt', 'name' => 'hàng hóa' ); $this->cart->insert($data);
Bài liên quan





Cách 1:
//Tạo file MY_Cart.php trong thư mục libraries của application //Copy function _insert() trong system/libraries/cart.php //Comment hoặc xóa dòng này // Validate the product name. It can only be alpha-numeric, dashes, underscores, colons or periods. // Note: These can be user-specified by setting the $this->product_name_rules variable. if ( ! preg_match("/^[".$this->product_name_rules."]+$/i", $items['name'])) { log_message('error', 'An invalid name was submitted as the product name: '.$items['name'].' The name can only contain alpha-numeric characters, dashes, underscores, colons, and spaces'); return FALSE; }mình xài thế này
class MY_Cart extends CI_Cart { public function MY_Cart() { parent::__construct(); $this->product_name_rules = '\d\D'; } }