View Full Version : Validation PHP Code in Setting
Bilderback
11-23-2008, 10:03 PM
This is driving me nuts.
Does anyone know how to use the Validation PHP Code box in a product setting?
I have a setting field as positive integer which I want to check if the size is in between 32 and 100.
If this returns false, I want to set a default value to be used in the product.
Would I have to initiate a plugin for this or is there an easy way to validate its size?
Example:
if($size <= 32 || $size >100) { $size = 64; }
Thanks for any help.
Dismounted
11-24-2008, 03:27 AM
The variable $data is used. As the verification is done through AJAX and only a true/false response is sent, I do not think there's a way (with the default vBulletin system) to override a setting through the verification system.
ReCom
11-24-2008, 09:18 AM
Enter return ($data >= 32 AND $data <= 100); in that box to check if the admin enters a number between 32 and 100. Just like Dismounted wrote, I don't think you can override invalid settings.
Bilderback
11-24-2008, 07:07 PM
Enter return ($data >= 32 AND $data <= 100); in that box to check if the admin enters a number between 32 and 100. Just like Dismounted wrote, I don't think you can override invalid settings.
That is what I originally tried in validation which displays the default invalid value error,
yet it still allows saving and returning the $data.
Ive also tried hooking the admin_options_processing to attempt to check the value
and return default if not 32><100 but I must be missing something.
Would using the admins_options_processing enable me to rewrite the $data value
before its saved to the database or would I have to write my own query?
Dismounted
11-25-2008, 04:39 AM
As you've said yourself, you will need to intercept the value before it is saved into the database.
vBulletin® v3.8.12 by vBS, Copyright ©2000-2025, vBulletin Solutions Inc.