Field validator documentation discrepancy

Field validator documentation discrepancy

csdatumcsdatum Posts: 30Questions: 10Answers: 0

I'm likely missing something, but in the document for field validation function it states that third parameter is the $opts that was passed as the second parameter into $field->validator($validator, $opts). This is the case when $validator is a string to reference a method within the Editor Validate class or another method defined in another custom class. But if $validator is an anonymous function, the third parameter is actually given as the instance of the field object instead of the $opts parameter.

Is this the expected behavior of an anonymous validator function? We are using the PHP library for Editor v1.6.5.

Thanks in advance for any help!

This question has an accepted answers - jump to answer

Answers

  • allanallan Posts: 61,847Questions: 1Answers: 10,134 Site admin
    Answer ✓

    Hi,

    Yes, currently that is indeed the way it is programmed. This is the call for a custom validator:

    $res = $func( $val, $data, $this, $instances );
    

    I didn't include the options as I didn't actually see the need for them. If you have an anonymous function, the options would just be in the function rather than needing to be passed in externally.

    Having said that, I absolutely see the discrepancy between the two forms there, and it isn't obvious at all in the documentation. That is something that needs to be addressed.

    Thanks!
    Allan

This discussion has been closed.