Answer the question
In order to leave comments, you need to log in
Why does continue_if_empty not work for FileInput?
I want to use Callback
but continue_if_empty
doesn't work for File. But everything works for Input
and Select
. I need help with this.
$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);
}
Answer the question
In order to leave comments, you need to log in
/**
* 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 |
* '-------------------'----------------'-----------------'-----------------'--------------------'
*/
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question