Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7931567
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T20:45:28+00:00 2026-06-03T20:45:28+00:00

I want to build a form to store some data. A Tarea could have

  • 0

I want to build a form to store some data. A “Tarea” could have many “Material” and a “Material” coul belong to one or more “Tarea”. The “Material” entity has a image property, with picture upload.

I can create a new “Material” with a picture with no problem. The problem becomes when I tried to create a new “Tarea”, when I submit the form, I´m getting “The file could not be found” error.

This is my Material entity with the file upload function:

/**
 * Gitek\HotelBundle\Entity\Material
 *
 * @ORM\Table()
 * @ORM\Entity(repositoryClass="Gitek\HotelBundle\Entity\MaterialRepository")
 */
class Material
{
    /**
     * @var integer $id
     *
     * @ORM\Column(name="id", type="integer")
     * @ORM\Id
     * @ORM\GeneratedValue(strategy="AUTO")
     */
    private $id;

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

    /**
     * @ORM\Column(type="string", nullable="true")
     *
     * @Assert\Image(maxSize = "500k")
     */
    protected $imagen;

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

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

    /**
    * @ORM\ManyToMany(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);
    }

This is my Tarea entity:

/**
 * Gitek\HotelBundle\Entity\Tarea
 *
 * @ORM\Table()
 * @ORM\Entity(repositoryClass="Gitek\HotelBundle\Entity\TareaRepository")
 */
class Tarea
{
    /**
     * @var integer $id
     *
     * @ORM\Column(name="id", type="integer")
     * @ORM\Id
     * @ORM\GeneratedValue(strategy="AUTO")
     */
    private $id;

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

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

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

    /** @ORM\ManyToOne(targetEntity="Gitek\HotelBundle\Entity\Tipotarea") */
    protected $tipotarea;

    /**
     * @ORM\ManyToMany(targetEntity="Material", inversedBy="tareas")
     * @ORM\JoinTable(name="material_tarea",
     *      joinColumns={@ORM\JoinColumn(name="tarea_id", referencedColumnName="id")},
     *      inverseJoinColumns={@ORM\JoinColumn(name="material_id", referencedColumnName="id")}
     * )
     */
    protected $materiales;

And this my MaterialType form type:

<?php

namespace Gitek\BackendBundle\Form;

use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\FormBuilder;

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

    public function getName()
    {
        return 'gitek_hotelbundle_materialtype';
    }
}

As I said, when I upload de form I get “The file could not be found” error. It´s seems like the validation fails.

Any help or clue?

UPDATE: If in my TareaController I comment the validation line it works correctly. Any clue?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-03T20:45:29+00:00Added an answer on June 3, 2026 at 8:45 pm

    The form does not include the fields for the Tarea so if in your validation you are requring it, it will fail. If you do not need it all the time you will want to setup validation groups so the validator know what to validate when.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need to store some data on the server in form of key,value pairs
I'm a newcomer to Rails. I want to build a simple form that determines
I'm designing some cross platform tool, and I want to store some read only
I want to build a back end of a general web form which contains
I'm using ASP.NET to build a form which has 3 DropDownLists and one GridView.
got a problem with one to one relations I have some Matches and i
In a webproject i have a complex form to build a dynamic query. When
I want to build a website that displays data from an external databases. The
With ExtJs 3.1 My Ext.form.ComboBox is built with a store in which some values
I have a nested form ,and i want to include city_id in the stores

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.