Salut à tous,
Dans mon formulaire d'inscription fait avec fosuserbundle je souhaiterais ajouter un champ ville, jusque la pas trop compliqué j'ai installé le bundle, l'autocomplétion marche bien.
Mais comme le champ est city_id et que j'ai un string du nom à la place (reims par exemple) il me dit :
Catchable Fatal Error: Object of class Acme\Bundle\UserBundle\Entity\City could not be converted to string
J'ai alors fais un truc assez dégeulasse 
1 2 3 4 5 6 7 8 9 10 11
|
<?php
# Retrouver l'id de la ville
if($_POST)
{
$town = $this->container->get('doctrine')
->getRepository('AcmeUserBundle:City')
->findOneBy(array('name_city' => $_POST['fos_user_registration_form']['city_id']));
$_POST['fos_user_registration_form']['city_id'] = $town->getId();
} |
Pour tenter de transformer mon nom en int mais ça fonctionne toujours pas avez vous une idée ?
Partager