review_submit_validation
Filter the array of validation messages.
You need to have a working knowledge of Hooks before you get started.
Parameters
| Name | Type | Description |
|---|---|---|
$validation |
parameter |
(array) validation messages |
$params |
parameter |
(array) associative array with contextual data |
Boilerplate Code
Use the boilerplate code to start using the filter, and add your own logic to modify the first argument and return it.
Clickfwd\Hook\Filter::add('review_submit_validation', function($validation, $params)
{
// Uncomment line below to view available data passed into hook
// fwd_dd($validation, $params);
return $validation;
});
Examples
Set Minimum Required Length for Review Comment
Clickfwd\Hook\Filter::add('review_submit_validation', function($validation, $params)
{
$comment = S2Array::get($params,'data.Review.comments');
$comment = strip_tags($comment);
if ( mb_strlen($comment) < 100 )
{
$validation[] = 'The review comment needs to be at least 100 characters';
}
return $validation;
}, 10);
Source Files
/controllers/reviews_controller.php