• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Cart library: how to extend library class regex validation without messing with the core?

Cart.php, line 31
var $product_name_rules    = '\.\:\-_ a-z0-9'; // alpha-numeric, dashes, underscores, colons or periods

While the pattern above will be valid in 99% of the cases I need to add a few allowed characters like a ? and a !
(building a shopping cart for book titles where some have a question or exclamation mark at the end)

Of course I can add those extra characters to the array. But this would mean that when I upgrade to a newer version of CI, I must keep track of such changes. Is there a better way in this case?

[eluser]Pascal Kriete[/eluser]
It's a public variable - so you can change it to anything you want.
$this->cart->product_name_rules = 'ponies';

Or you could [url=http://ellislab.com/codeigniter/user-guide/general/core_classes.html]extend the library[/code] and just set it in there, which will then be in effect globally.

Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  

  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2021 MyBB Group.