Setting validation error on var_save not working
Hey Low,
I’m having some trouble with a field type I’m developing setting an error message for validation failure on the var_save method. I’m setting:
$this->error_msg = $error;
return false;
But no luck.
I looked through the code a little bit and I can see in mcp.low_variables where the error_msg is set if the return is false, but the object it's trying to get the property off of (Low_variables_type) has error_msg set to null. in the private _ft property I can see my error_msg property on the field type class.
Any ideas?
Replies
Low 2 May 2016 07:33
I see what you mean. The var is skipped correctly, but the error message is not shown. As a workaround, change the save method in type.low_variables.php to this:
I'll incorporate that fix (or something similar) in the next version. Probably nicer to use a function call at some point...
TJ Draper 2 May 2016 15:06
Thanks! That works in that the error is shown, but my validation method is returning some HTML which is being converted to entities so that it looks like this on the front end:
Low 2 May 2016 15:26
That would be correct. Right now, it doesn't accept markup. What does EE do natively in the publish form, here?