English 中文(简体)
在许多Tomany表格中的验证错误
原标题:Validation error on ManyToMany form
  • 时间:2012-05-10 10:50:03
  •  标签:
  • symfony

我想建立一个表格储存一些数据。 “Tarea”可能有许多“Material”和“Material”混合物属于一个或多个“Tarea”。 “Material”实体有图像财产,有照片上载。

我可以创造新的“信息”,无问题。 当我提交表格时,我试图制造新的“塔里亚”时,我就把“档案无法找到”错误带给我。

这是我拥有文件上载功能的材料实体:

/**
 * GitekHotelBundleEntityMaterial
 *
 * @ORMTable()
 * @ORMEntity(repositoryClass="GitekHotelBundleEntityMaterialRepository")
 */
class Material
{
    /**
     * @var integer $id
     *
     * @ORMColumn(name="id", type="integer")
     * @ORMId
     * @ORMGeneratedValue(strategy="AUTO")
     */
    private $id;

    /**
     * @var string $nombre
     *
     * @ORMColumn(name="nombre", type="string", length=100)
     */
    private $nombre;

    /**
     * @ORMColumn(type="string", nullable="true")
     *
     * @AssertImage(maxSize = "500k")
     */
    protected $imagen;

    /**
     * @var datetime $created_at
     *
     * @ORMColumn(name="created_at", type="datetime")
     */
    private $created_at;

    /**
     * @var datetime $updated_at
     *
     * @ORMColumn(name="updated_at", type="datetime")
     */
    private $updated_at;

    /**
    * @ORMManyToMany(targetEntity="Tarea", mappedBy="materiales")
    */
    protected $tareas;

    public function __construct()
    {
        $this->created_at = new DateTime();
        $this->updated_at = new DateTime();
    }

    public function __toString()
    {
        return $this->getNombre();
    }

    /**
     * Sube la foto de la incidencia copiándola en el directorio que se indica y
     * guardando en la entidad la ruta hasta la foto
     *
     * @param string $directorioDestino Ruta completa del directorio al que se sube la foto
     */
    public function subirImagen($directorioDestino)
    {
        if (null === $this->imagen) {
            return;
        }

        $nombreArchivoImagen = uniqid( material- ). -1. .$this->imagen->guessExtension();

        $this->imagen->move($directorioDestino, $nombreArchivoImagen);

        $this->setImagen($nombreArchivoImagen);
    }

这是我的塔里亚实体:

/**
 * GitekHotelBundleEntityTarea
 *
 * @ORMTable()
 * @ORMEntity(repositoryClass="GitekHotelBundleEntityTareaRepository")
 */
class Tarea
{
    /**
     * @var integer $id
     *
     * @ORMColumn(name="id", type="integer")
     * @ORMId
     * @ORMGeneratedValue(strategy="AUTO")
     */
    private $id;

    /**
     * @var string $nombre
     *
     * @ORMColumn(name="nombre", type="string", length=100)
     */
    private $nombre;

    /**
     * @var datetime $created_at
     *
     * @ORMColumn(name="created_at", type="datetime")
     */
    private $created_at;

    /**
     * @var datetime $updated_at
     *
     * @ORMColumn(name="updated_at", type="datetime")
     */
    private $updated_at;

    /** @ORMManyToOne(targetEntity="GitekHotelBundleEntityTipotarea") */
    protected $tipotarea;

    /**
     * @ORMManyToMany(targetEntity="Material", inversedBy="tareas")
     * @ORMJoinTable(name="material_tarea",
     *      joinColumns={@ORMJoinColumn(name="tarea_id", referencedColumnName="id")},
     *      inverseJoinColumns={@ORMJoinColumn(name="material_id", referencedColumnName="id")}
     * )
     */
    protected $materiales;

以及我的材料 类型类型:

<?php

namespace GitekBackendBundleForm;

use SymfonyComponentFormAbstractType;
use SymfonyComponentFormFormBuilder;

class MaterialType extends AbstractType
{
    public function buildForm(FormBuilder $builder, array $options)
    {
        $builder
            ->add( nombre )
            ->add( imagen )
        ;
    }

    public function getName()
    {
        return  gitek_hotelbundle_materialtype ;
    }
}

正如我所说的那样,当我上载时,我发现“档案无法找到”错误。 这似乎与验证失败一样。

任何帮助或cl?

UPDATE:如果在我的TareaController中我对验证线作正确评论的话。 任何cl?

最佳回答

表格不包括塔里亚的田地,这样,如果你在鉴定中重新定性,就会失败。 如果你不需要的话,你会想设立验证小组的所有时间,以便验证人知道何时确认。

问题回答

暂无回答




相关问题
Symfony 5, I can t start the server

I develop a symfony project and everything was fine. But since yesterday I can not launch the server: enter image description here The commands symfony server:start and symfony server:stop don t work ...

learning symfony 1.4 will be good when using symfony 2.0?

I know that the architecture is different in symfony 2.0 but im learning 1.4 right now. I wonder if this knowledge i gain about 1.4 will be usable for 2.0 in some extent or will it be a total waste ...

Is symfony 2.0 stable enough to use? [closed]

I wonder if Symfony 2.0 is stable enough to use? Because I ve never used Symfony before. It seems that Symfony 2 is much better than the previous version and I don t want to relearn/recode ...

your experience using symfony 2.0 [closed]

I m going to start a new project that s building web apps from scratch. I have been thinking about using symfony framework for this project. Should I start using symfony 2.0 or stick with 1.4 ? I ...

How to increase the session timeout in Symfony

I would like to know how to increase the session timeout in symfony. Is it enough to only adjust the symfony configuration settings or must I also configure anything in my php.ini file?

How stable or unstable is symfony 2.0? [closed]

Well, I know it s a preview, and I know it says that it s not yet ready for production, and yet I dare ask the question. I need to start building a pretty big application, which is planned to go live ...

热门标签