additional server side validation custom fields

  • Posts: 3
  • Thank you received: 0
12 years 1 week ago #75803

I need to write some more detailed validation code (not just only if the filed is empty, or not) for an item set custom field for our products.
Where can I write this code?

Maik

Please Log in or Create an account to join the conversation.

  • Posts: 82863
  • Thank you received: 13372
  • MODERATOR
12 years 1 week ago #75871

You should create a new hikashop plugin and implement the trigger onFieldsLoad($types) and the corresponding class of the custom field type in order to add a new type of custom field.

Something like that:

<?php
class plgHikashopMyfield extends JPlugin
{
function __construct(&$subject, $config) {
parent::__construct($subject, $config);
}

function onFieldsLoad(&$fields) {
$me = null;
$me->name = 'myfield';
$me->text = 'my field';
$me->js = 'allTypes["plg.myfield"] = new Array("required","default","columnname");';
$fields[] = $me;
}
}

if(defined('HIKASHOP_COMPONENT')) {
class hikashopMyfield{
//there you should define the different functions of the field classes: show (to display the value entered), display (to display the field), check (to check the value entered). You can take example on the classes in the file administrator/components/com_hikashop/classes/field.php
}
}

Please Log in or Create an account to join the conversation.

Time to create page: 0.051 seconds
Powered by Kunena Forum