Code Monkey home page Code Monkey logo

Comments (2)

rbaarsma avatar rbaarsma commented on June 28, 2024

Well I've been on this a few hours. I first worked on a solution in the controller. This I eventually created:

    $form->setRequest($request);

    // check all fields of the form 
    $fname = $form->getName();
    foreach($form->getIterator() as $col=>$val)
    {
        $getter = 'get'.ucfirst(str_replace("_","",$col));
        $val = $entity->$getter();
        $sess_name = "_spin_file_upload_{$fname}_$col";

        // if session was already created
        if ($this->get('session')->has($sess_name))
        {
            if ($val === null)
            {
                $setter = 'set'.ucfirst(str_replace("_","",$col));
                $entity->$setter( ( $this->get('session')->get($sess_name) ) );
            }

            // remove the session if the form is valid
            // note: when the user closes the browser on validation errors the session remains.
            if ($form->isValid())
                $this->get('session')->set($sess_name, null);
        }

        // save all images to session, so we can retrieve them if form has validation errors
        if ($val instanceof Picture && !$form->isValid())
            $this->get('session')->set($sess_name, $val);
    }

    // continue normal form action
    if ($form->isValid())
    {

I've also tried to get this same function in the EventSubscriber structure of the forms, but somehow I can't get it to work there.
I hope this helps

from vlabsmediabundle.

choomz avatar choomz commented on June 28, 2024

Hi,

It looks strange, image in a form is a standard behavior of this bundle. It looks like a configuration error.

Can you please paste me your config for this field ?

from vlabsmediabundle.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.