Jump to content

[SOLVED]Override Validate::IsGenericName(); in AdminFeaturesController?


venditdevs

Recommended Posts

I managed to override  IsGenericName()  because i have to accept these chars < = > in the Feature values.

 

I don't want to break other validations in Prestashop so the desired solution is to add a custom function for this purpose. 

 

How do i get Prestashop to use this function ?

I can't find the use of Validate::IsGenericName() In the AdminFeaturesController.php but it is using it.

 

Is there anyone who can help?

Edited by venditdevs (see edit history)
Link to comment
Share on other sites

I think you should search it in classes/Feature.php and classes/FeatureValue.php:

 

There you have definitions like this:

 

public static $definition = array(
'table' => 'feature',
'primary' => 'id_feature',
'multilang' => true,
'fields' => array(
'position' => array('type' => self::TYPE_INT, 'validate' => 'isInt'),
 
// Lang fields
'name' => array('type' => self::TYPE_STRING, 'lang' => true, 'validate' => 'isGenericName', 'required' => true, 'size' => 128),
),
);
 

 

and

 

public static $definition = array(
'table' => 'feature_value',
'primary' => 'id_feature_value',
'multilang' => true,
'fields' => array(
'id_feature' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId', 'required' => true),
'custom' => array('type' => self::TYPE_BOOL, 'validate' => 'isBool'),
 
// Lang fields
'value' => array('type' => self::TYPE_STRING, 'lang' => true, 'validate' => 'isGenericName', 'required' => true, 'size' => 255),
),
);
 
 
Which you can change into your own function 'isMyAdjustedGenericName' that you create in an override of classes/Validate.php, (or, you can just replace 'isGenericName'  with 'isAnything' if you want it to accept just all chars)
 
Hope this helps,
pascal
  • Like 1
Link to comment
Share on other sites

Thanks PascalVG you really saved me on this one  :wub:  :)

Another challenge have risen now :mellow: And i don't know where to look ...well ...i think it's a TPL file. I will explain in a new topic

 

Thanks again for your help!     

Link to comment
Share on other sites

  • 2 years later...

Hy

 

Please, how enable HTML on the `delay` field  of  'ps_carrier_lang` table.

i've some html link in this field and i'm looking for their execution

 

I've try with 'type' => self::TYPE_HTML, bot not execute as html

   'delay' =>                    array('type' => self::TYPE_HTML, 'lang' => true, 'validate' => 'isAnything', 'required' => true, 'size' => 628),

Thank's

Best regards Thomas

Edited by webconcept76 (see edit history)
Link to comment
Share on other sites

  • 3 months later...

Hy

 

Please, how enable HTML on the `delay` field  of  'ps_carrier_lang` table.

i've some html link in this field and i'm looking for their execution

 

I've try with 'type' => self::TYPE_HTML, bot not execute as html

   'delay' =>                    array('type' => self::TYPE_HTML, 'lang' => true, 'validate' => 'isAnything', 'required' => true, 'size' => 628),

Thank's

Best regards Thomas

 

 

 

pretty old topics , but just as a help for those who are still searching,  in order to enable HTML, you have to use 'isCleanHTML' validation method. here is a complete list of PrestaSHop object model validation methods....

Link to comment
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
×
×
  • Create New...