From 0456eeb33974c907498b2c6eec830cc22320e5aa Mon Sep 17 00:00:00 2001 From: Maxime Renou Date: Fri, 22 Feb 2019 19:25:42 +0100 Subject: [PATCH] checked & co --- ValidatorBundle/Validator.php | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/ValidatorBundle/Validator.php b/ValidatorBundle/Validator.php index b2347ae..b22a031 100644 --- a/ValidatorBundle/Validator.php +++ b/ValidatorBundle/Validator.php @@ -6,6 +6,7 @@ use Bluesquare\StorageBundle\Exceptions\MimeTypeException; use Bluesquare\StorageBundle\Storage; use Symfony\Component\HttpFoundation\RequestStack; use Symfony\Contracts\Translation\TranslatorInterface; +use Symfony\Component\HttpFoundation\JsonResponse; class Validator { @@ -172,7 +173,16 @@ class Validator public function checked($field) { - return !is_null($this->get($field)) || $this->get($field) != '0' || $this->get($field) != 0; + return $this->post() ? ( + !is_null($this->get($field)) + ) : ( + !is_null($this->value($field)) && $this->value($field) != 0 && $this->value($field) != false + ); + } + + public function isChecked($field) + { + return $this->has($field); } public function getFile($name)