Hi
I am creating a module within Expression Engine 2, which utilises the form validation class processed via template tags, however when I attempt to use a callback validation rule no method is called.
Are callback validation rules supported in Expression Engine and if so could someone point me to a successful example?
Thanks
Yes. If you look at the EE_Form_validation.php you will see this
/**
* Sets additional object to check callbacks against such as fieldtypes
* to allow third-party fieldtypes to validate their settings forms
*
* @param object Fieldtype to check callbacks against
* @return void
*/
public function set_fieldtype($fieldtype)
{
$this->_fieldtype = $fieldtype;
}Here is an example usage:
public function submit() {
...
ee()->form_validation->set_fieldtype($this);
ee()->form_validation->set_rules('field_x', lang('field_x'), 'required|callback_field_x_check');
...
}
public function field_x_check() {
// Validate
return TRUE;
}Refer to the Codeigniter Form Validation docs for more details on how to use the callback validation.
Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.