Callback
, но continue_if_empty
не работает для File. Но все работает для Input
и Select
. Мне нужна помощь с этим.$this->add([
'name' => 'images',
'required' => false,
'allow_empty' => true,
'continue_if_empty' => true,
'type' => FileInput::class,
'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);
}
/**
* Configuration of the input filter for element based on the provided specification.
* Specification can contain any of the following:
*
* .-------------------.----------------.-----------------.-----------------.--------------------.
* | continue_if_empty | required | allow_empty | Is empty valid? | Apply other filter |
* |-------------------+----------------+-----------------+-----------------+--------------------|
* | false (default) | true (default) | false (default) | false | Not |
* | false (default) | true (default) | true | true | Not |
* | false (default) | false | false (default) | true | Not |
* | true | true (default) | false (default) | true | Yes |
* |-------------------+----------------+-----------------+-----------------+--------------------|
* | false (default) | false | true | true | Not |
* | true | true (default) | true | true | Yes |
* | true | false | false (default) | true | Yes |
* | true | false | true | true | Yes |
* '-------------------'----------------'-----------------'-----------------'--------------------'
*/