IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

Symfony PHP Discussion :

[Form] Migration vers Symfony 2.1


Sujet :

Symfony PHP

  1. #1
    Futur Membre du Club
    Homme Profil pro
    Inscrit en
    Septembre 2011
    Messages
    7
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations forums :
    Inscription : Septembre 2011
    Messages : 7
    Points : 6
    Points
    6
    Par défaut [Form] Migration vers Symfony 2.1
    Bonjour à tous.

    Je viens de migrer mon projet de Symfony 2.0.X vers la version 2.1.5.

    J'utilise "entity_id" comme type de champ (non inclus par défaut, https://github.com/Gregwar/FormBundle) et j'ai une erreur qui apparaît quand je valide mon form

    Mon code est le suivant pour créer le form, il fonctionnait sans probleme
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
     
            $builder
             ->add('company', 'entity_id', array(
                                'class' => '\Ambinter\AdminBundle\Entity\MonEntity',
                                'property'=>'supplier.company',  // l'erreur semble venir de là
                                'hidden' => true,
                                'property_path'=>'monEntity'
                ))
    et mon code twig
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
     
    {% for item in form.items %}
    {{ form_widget (item.company) }} {{ item.vars.value.monEntity.supplier.company }}
    ...
    maintenant j'ai l'erreur suivante :
    Exception detected!
    Unrecognized field: supplier.company
    500 Internal Server Error - ORMException
    Stack Trace

    in /home/splach/Symfony/vendor/doctrine/orm/lib/Doctrine/ORM/ORMException.php at line 70 -+
    public static function unrecognizedField($field)
    {
    return new self("Unrecognized field: $field");
    }
    /**
    at ORMException ::unrecognizedField ('supplier.company')
    in /home/splach/Symfony/vendor/doctrine/orm/lib/Doctrine/ORM/Persisters/BasicEntityPersister.php at line 1505 -+
    at BasicEntityPersister ->getSelectConditionStatementColumnSQL ('supplier.company', null)
    in /home/splach/Symfony/vendor/doctrine/orm/lib/Doctrine/ORM/Persisters/BasicEntityPersister.php at line 1452 -+
    at BasicEntityPersister ->getSelectConditionStatementSQL ('supplier.company', 'monSupplier', null)
    in /home/splach/Symfony/vendor/doctrine/orm/lib/Doctrine/ORM/Persisters/BasicEntityPersister.php at line 1525 -+
    at BasicEntityPersister ->_getSelectConditionSQL (array('supplier.company' => 'monSupplier'), null)
    in /home/splach/Symfony/vendor/doctrine/orm/lib/Doctrine/ORM/Persisters/BasicEntityPersister.php at line 1018 -+
    at BasicEntityPersister ->_getSelectEntitiesSQL (array('supplier.company' => 'monSupplier'), null, '0', '1', null, null)
    in /home/splach/Symfony/vendor/doctrine/orm/lib/Doctrine/ORM/Persisters/BasicEntityPersister.php at line 668 -+
    at BasicEntityPersister ->load (array('supplier.company' => 'monSupplier'), null, null, array(), '0', '1', null)
    in /home/splach/Symfony/vendor/doctrine/orm/lib/Doctrine/ORM/EntityRepository.php at line 171 -+
    at EntityRepository ->findOneBy (array('supplier.company' => 'monSupplier'))
    in /home/splach/Symfony/vendor/gregwar/form-bundle/Gregwar/FormBundle/DataTransformer/EntityToIdTransformer.php at line 131 -+
    at EntityToIdTransformer ->reverseTransformSingleEntity ('monSupplier')
    in /home/splach/Symfony/vendor/gregwar/form-bundle/Gregwar/FormBundle/DataTransformer/EntityToIdTransformer.php at line 99 -+
    at EntityToIdTransformer ->reverseTransform ('monSupplier')
    in /home/splach/Symfony/vendor/symfony/symfony/src/Symfony/Component/Form/Form.php at line 1022 -+
    at Form ->normToModel ('monSupplier')
    in /home/splach/Symfony/vendor/symfony/symfony/src/Symfony/Component/Form/Form.php at line 590 -+
    at Form ->bind ('monSupplier')
    in /home/splach/Symfony/vendor/symfony/symfony/src/Symfony/Component/Form/Form.php at line 539 -+
    at Form ->bind (array('company' => 'monSupplier', 'reference' => 'T5496113', 'quantity' => '10', 'quantityType' => 'mg', 'price' => '', 'currency' => '2', 'delay' => '0', 'remark' => ''))
    in /home/splach/Symfony/vendor/symfony/symfony/src/Symfony/Component/Form/Form.php at line 539 -+
    at Form ->bind (array(array('company' => 'monSupplier', 'reference' => 'T5496113', 'quantity' => '10', 'quantityType' => 'mg', 'price' => '', 'currency' => '2', 'delay' => '0', 'remark' => ''), array('company' => 'monSupplier', 'reference' => 'T5496113', 'quantity' => '10', 'quantityType' => 'mg', 'price' => '12.00', 'currency' => '2', 'delay' => '0', 'remark' => '')))
    in /home/splach/Symfony/vendor/symfony/symfony/src/Symfony/Component/Form/Form.php at line 539 -+
    at Form ->bind (object(Request))
    in /home/splach/Symfony/src/Ambinter/AdminBundle/Controller/ItemRefController.php at line 244 -+
    at ItemRefController ->FormItemRefAction (object(Item), null)
    at call_user_func_array (array(object(ItemRefController), 'FormItemRefAction'), array(object(Item), null))
    in kernel.root_dir/bootstrap.php.cache at line 1426 -+
    at HttpKernel ->handleRaw (object(Request), '1')
    in kernel.root_dir/bootstrap.php.cache at line 1390 -+
    at HttpKernel ->handle (object(Request), '1', true)
    in kernel.root_dir/bootstrap.php.cache at line 1566 -+
    at HttpKernel ->handle (object(Request), '1', true)
    in kernel.root_dir/bootstrap.php.cache at line 617 -+
    at Kernel ->handle (object(Request))
    in /home/splach/Symfony/web/app_dev.php at line 25 -+
    ...
    Si quelqu'un a une idée, je lui en serais très reconnaissant car je sèche depuis un moment !
    Merci d'avance pour votre aide, j'espère être suffisamment clair dans mes explications.

  2. #2
    Membre éclairé
    Homme Profil pro
    Technicien maintenance
    Inscrit en
    Août 2011
    Messages
    477
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 54
    Localisation : France

    Informations professionnelles :
    Activité : Technicien maintenance
    Secteur : Administration - Collectivité locale

    Informations forums :
    Inscription : Août 2011
    Messages : 477
    Points : 677
    Points
    677
    Par défaut
    Bonjour,

    Beaucoup de chose à changer entre la version 2.0 et 2.1 dans le compenant form.

    Toutefois, de ce que je lis, ton formulaire s'affiche correctement.

    Je pense que le problème est dans le controller après la validation.

    Essaye de dumper le retour de ton form après le isValid().

  3. #3
    Futur Membre du Club
    Homme Profil pro
    Inscrit en
    Septembre 2011
    Messages
    7
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations forums :
    Inscription : Septembre 2011
    Messages : 7
    Points : 6
    Points
    6
    Par défaut
    Salut,

    J'ai tenté d'afficher quelques "echo" pour voir où ça plante. Apparement, c'est juste après le
    Le form s'affiche bien une première fois mais j'ai l'erreur quand je tente de valider ce dernier.

  4. #4
    Membre éclairé
    Homme Profil pro
    Technicien maintenance
    Inscrit en
    Août 2011
    Messages
    477
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 54
    Localisation : France

    Informations professionnelles :
    Activité : Technicien maintenance
    Secteur : Administration - Collectivité locale

    Informations forums :
    Inscription : Août 2011
    Messages : 477
    Points : 677
    Points
    677
    Par défaut
    Salut,

    As tu mis à jour le Formbundle ?

    Je te conseille aussi de regarder à la racine du framework sur github, pour voir tous les changements autour du compenent form.

    Je n'utilise pas ce bundle, difficile de te dire si c'est lui qui coince. Toutefois l'erreur qui est remonté est de doctrine qui ne trouve pas ce champ.

    Tu peux dump le form->bind($request); pour voir si cela correspond à ce que tu attends.

Discussions similaires

  1. [2.x] Migration vers Symfony 2.1
    Par Cibou dans le forum Symfony
    Réponses: 0
    Dernier message: 12/09/2012, 09h14
  2. [1.x] migration du php5 vers symfony
    Par abdelmajid_daosabah dans le forum Symfony
    Réponses: 4
    Dernier message: 09/03/2009, 11h29
  3. Migration Forms 6i vers Forms 9i ou 10g
    Par essse dans le forum Forms
    Réponses: 38
    Dernier message: 08/01/2008, 18h25
  4. Réponses: 1
    Dernier message: 05/11/2007, 07h30
  5. [Forms]migration forms 6 vers forms 8
    Par anthonychery dans le forum Oracle
    Réponses: 7
    Dernier message: 17/11/2004, 17h54

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo