I want use Callback
validation but continue_if_empty
not working for File
it’s returning No file was uploaded
error. But everything working for Input
and Select
. I need help with this.
$this->add([
'name' => 'images',
'type' => FileInput::class,
'required' => false,
'allow_empty' => true,
'continue_if_empty' => true,
'filters' => [
[
'name' => Rename::class,
'options' => [
'target' => '/var/www/project/public/website/content/tmp/image_' . md5(time()),
'randomize' => true,
],
],
],
'validators' => [
[
'name' => Callback::class,
'options' => [
'callback' => [$this, 'imageValidator'],
],
],
],
]);
public function imageValidator($value, $context)
{
dd($context);
}