Jump to content

Disable field validation in admin product information page


Mykhailo
 Share

Recommended Posts

Hi!

 

I have extended length of standard EAN13 field in database, but field validation in back-end stops me from entering new longer values there. How can I disable this validation? Didn't find anything in informations.tpl file. PS 1.6

 

post-801467-0-24872300-1401909885_thumb.png

Share this post


Link to post
Share on other sites

probably need to edit two files:

classes/Validate.php:

 

find function:

	 * Check for barcode validity (EAN-13)
	 *
	 * @param string $ean13 Barcode to validate
	 * @return boolean Validity is ok or not
	 */
	public static function isEan13($ean13)
	{
		return !$ean13 || preg_match('/^[0-9]{0,13}$/', $ean13);
	}

and edit as needed.

 

Then edit file: classes/product.php and edit this line in public static $definition = array(...) :

 
'ean13' => array('type' => self::TYPE_HTML, 'validate' => 'isEan13' , 'size' => 13),

 

remove or modify the size and change to HTML type.

 

N.B.  Instead of editing the Validate.php function isEan13, you can also just change the 'validate' => 'isEan13' check to something else, like:

 

'ean13' =>  array('type' => self::TYPE_HTML, 'validate' => 'isCleanHtml'),
 
 
or so.
 
Hope this helps,
pascal

Share this post


Link to post
Share on other sites

  • 6 years later...

Hi Pascal,

tht's some years ago, but I have the same issue now. I want to switch off validation for UPC or ISBN as I don't need  both values and I want to use those fields for storing other values.

I changed for both values

validate.php to >> return !$XXXX || preg_match('/^[0-9]{0,13}$/', $XXXX);

and

product.php to >> 'XXXX' => array('type' => self::TYPE_HTML, 'validate' => 'XXXX' , 'size' => 13),

Still it does not change anything in the validation of the fields. Cache was cleared in shop/settings/general.

See both files attached. What am I doing wrong?

Product.php Validate.php

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...

Important Information

Cookies ensure the smooth running of our services. Using these, you accept the use of cookies. Learn More