我正在用fos用户注册表单做一个表单集合。
Warning: Invalid argument supplied for foreach() in C:\xampp\htdocs\symfony-bootstrap\vendor\symfony\symfony\src\Symfony\Component\Validator\Mapping\Loader\AnnotationLoader.php on line 65
如果我完成表单并发送它,它确实会继续存在,但视图显示此错误10次,并且我没有看到任何人出现此错误。
这是我的注册表类型。
namespace sava\UserBundle\For
我想在一个特征上使用回调验证。例如:
<?php
namespace Vendor\Bundle\Entity;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Validator\Constraints as Assert;
use Symfony\Component\Validator\ExecutionContext;
/**
* @Assert\Callback(methods={"validateReview"}, groups={"review"})
*/
trait Rev
我有一个Symfony 2.8.9应用程序,其中一个表单在行中造成一个很大的模糊错误
$form->handleRequest($request);
我的表单非常简单:只有一个id和一个commentaire字段。该错误似乎发生在验证任务期间(下面的完整跟踪)。
[ERROR 1824] Element '{http://symfony.com/schema/dic/constraint-mapping}class', attribute 'name': 'Symfony\Component\Form\Form' is not a vali
我有一个用户类,其中包含一些字段的自定义验证。当我提交表单时,我得到以下错误:
警告:..../vendor/doctrine/lib/Doctrine/ORM/Mapping/ClassMetadataFactory.php第223行中不存在class_parents() Function.class父母:类
有人能告诉我我做错了什么吗?
这是我的用户类:
<?php
namespace MyBundle\Entity;
use Doctrine\ORM\Mapping as ORM;
use FOS\UserBundle\Entity\User as BaseUser;
us
我想使用约束来制作一个测试单元,但是在运行测试时有这个错误。
这是我的不同类和运行phpunit后获得的错误。
use Symfony\Component\Validator\Constraint;
/**
* @Annotation
*/
class Age18 extends Constraint
{
public $message = 'Vous devez avoir 18 ans.';
}
use Symfony\Component\Validator\Constraint;
use Symfony\Component\Validator\Const
我有一个应用程序,我的开发环境是nginx,它工作得很好。产品为apache、PHP7.3、mysql 5.7 我收到以下错误: Uncaught PHP Exception Symfony\Component\Validator\Exception\MappingException: "Extension DOM is required." at /var/www/vendor/symfony/validator/Mapping/Loader/XmlFileLoader.php line 181 {"exception":"[object] (Sym
在从2.8升级到3.0之后,我和APC有问题。
[2015-12-05 17:03:05] php.CRITICAL: Fatal Error: Class 'Symfony\Component\Validator\Mapping\Cache\ApcCache' not found {"type":1,"file":"/var/www/vhosts/host/httpdocs/var/cache/prod/appProdProjectContainer.php","line":1102,"level"
我使用Symfony 2.3.9和磷评注包1.*。
当我创建一个磷注释时,我出现了这个错误。
这里是错误
FatalErrorException: Error: Class 'Symfony\Component\Validator\Constraints\MinLength' not found in vendor/symfony/symfony/src/Symfony/Component/Validator/Mapping/Loader/AbstractLoader.php line 64
有什么帮助吗?
相同的
此代码适用于Symfony 2.4.5,但不适用于Symfony 2.5:
这是我在Symfony 2.4.5中使用的HRAPI扩展类,而不是Symfony 2.5中的
<?php
namespace HardCoreMore\HRAPIBundle\DependencyInjection;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\Config\FileLocator;
use Symfony\Component\HttpKernel\DependencyInj
我使用Symfony3和表单。我有一个formType,我想测试它。我遵循这篇文章:
我的formType如下:
namespace AppBundle\Form;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\Extension\Core\Type\IntegerType;
use Symfony\Component\Form\Extension\Core\Type\TextType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfo
我似乎做了正确的设置,但仍然不能工作,即它不会设置正确的数据库表。事实上,它完全忽略了@UniqueEntity注释。
我正在设置一个,其中类别的标题不应该在相同的parent_id中重复。
所以,看看和我之前构建的一些代码,这应该是可行的:
/App/实体/类别
namespace App\Entity;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
use Doctrine\Common\Collections\ArrayCollection;
use Gedmo\Mapping\
我对Symfony2表单+实体+验证过程有一些疑问。以此代码为例(/src/Common/CommonBundle/Resources/config/validation.yml):
Common\CommonBundle\Entity\AddressExtraInfo:
properties:
town:
- NotBlank:
message: "This value should not be blank"
- Length:
min:
我使用的是Symfony 4、ApiPlatform 1和VichUploaderBundle 1。
按声明做了所有事情,但得到了错误:Cannot validate values of type \"NULL\" automatically. Please provide a constraint.
我甚至不知道如何调试它,- error和回溯跟踪是如此无用。从哪里开始搜索?救命求你了。
我的形象实体:
<?php
namespace App\Entity;
use ApiPlatform\Core\Annotation\ApiProperty;
use ApiP
我正在尝试让Symfony的UniqueEntity验证器为我的信条实体工作。Symfony验证器已经连接并正常工作,但是Symfony\Bridge的UniqueEntity更具挑战性,显示以下错误:
PHP Fatal error: Class 'doctrine.orm.validator.unique' not found in /app/vendor/symfony/validator/Symfony/Component/Validator/ConstraintValidatorFactory.php on line 46
看起来好像ValidatorFactory
我的Symfony rest API有问题。我有一个控制器:
<?php
namespace App\Controller;
use App\Entity\Post;
use App\Service\ErrorDecoratorService;
use App\Service\PostService;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\Routing\A
我的问题涉及用户表单中的一个字段,即用户名。由于断言验证适用于实体中的其他字段,因此我发现这样的行为很奇怪-跳过我为用户实体中的用户名属性指出的断言规则,并将null属性传递给userFormNewHandler,这会产生错误,特别是当我发现它与其他字段没有什么不同的时候。我在想,我错过了什么? UserType.php: <?php
namespace App\UserBundle\Form\Type;
use App\UserBundle\Entity\User;
use Symfony\Component\Form\AbstractType;
use Symfony\Compo
当我尝试登录时:
[Semantical Error] The annotation "@Doctrine\ORM\Mapping\Model" in class AppBundle\Entity\User does not exist, or could not be auto-loaded.
我的实体:
namespace AppBundle\Entity;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\ORM\Mapping as ORM;
use Symfon
此方法位于我的实体类中。
public function validateStartDate(ExecutionContextInterface $context)
{
if ($this->getEndDate() < $this->getStartDate()){
$context->addViolationAt(
'endDate',
'End date cannnot be before Start date',
array(),
我一直在尝试使用Symfony3上的服务创建一个带有参数的自定义验证约束。
问题是我在提交表单后得到了一个异常:
Catchable Fatal Error: Argument 1 passed to OC\PlatformBundle\Validator\AntifloodValidator::__construct() must be an instance of Symfony\Component\HttpFoundation\RequestStack, none given, called in C:\wamp\www\Symfony\vendor\symfony\symfony\sr
在通过composer更新我的代码之前,我的表单单元测试正在工作。它现在在扩展模拟上失败了。下面是错误:
Argument 1 passed to Symfony\Component\Form\Extension\Validator\Type\FormTypeValidatorExtension::__construct() must be an instance of Symfony\Component\Validator\ValidatorInterface, instance of Mock_ValidatorInterface_14b95ba0 given
以下是我的作曲家必备部分:
致命错误:调用未定义方法Doctrine\ORM\PersistentCollection::getPath()
用户实体: User.php
namespace AppBundle\Entity;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Validator\Constraints as Assert;
use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
use Symfony\Component\Security\Core\User\Us
我有一个实体媒体,它保护文件值
<?php
namespace Chiave\MediaBundle\Entity;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Validator\Constraints as Assert;
use Symfony\Component\HttpFoundation\File\UploadedFile;
/**
* @ORM\Table(name="media")
* @ORM\Entity
* @ORM\HasLifecycleCallbacks
*/
cl
我正在构建一个自定义验证器,它需要验证db中两个表单域的值,以便通过此约束。
我的问题是:ContractValidator的validation方法的签名中只有一个$value,那么我如何访问多个字段中的值来进行验证呢?
下面是一个典型的自定义验证器:
namespace Acme\WebsiteBundle\Validator\Constraints;
use Symfony\Component\Validator\Constraint;
use Symfony\Component\Validator\ConstraintValidator;
class MyCustomValidat
我有两个实体游戏和GameSource。游戏只有一个GameSource。
Game.php
<?php
namespace AppBundle\Entity;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Validator\Constraints as Assert;
use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
/**
* @ORM\Table(name="game")
* @ORM\Entity(repositor
当我在发布后试图验证我的用户实体表单时,我得到了一个
ContextErrorException: Catchable Fatal Error: Argument 1 passed to Symfony\Component\Validator\Mapping\ClassMetadata::addConstraint() must be an instance of Symfony\Component\Validator\Constraint, array given
确实,它是一个数组,因为它在validation.yml中是这样定义的
Transplan\CoreBundle\Entity\