[symfony][Doctrine][sfWidgetFormSelect] Problème de violation de la base de donnés
Bonjour à tous,
Voilà mon problème, j'ai une base de donnée qui comporte une table 'Picture' et une table 'Person', et l' "author" d'une 'Picture' pointe vers l' "id" d'une 'Person'.
Dans mon formulaire pour créer une nouvelle 'Picture j'ai fait, pour résumer mon problème :
Code:
1 2 3 4 5 6 7 8 9 10
|
$this->form = new sfForm();
$this->form->setWidgets(array(
'author' => new sfWidgetFormInputText(array('label'=>'photographe'))
));
$this->form->setValidators(array(
'author' => new sfValidatorString()
));
$this->form->getWidgetSchema()->setNameFormat('photo[%s]'); |
Ici, lorsque je tape "PMP" dans la balise InputText, je n'ai aucun problème (PMP est un 'id' qui est déjà dans la base de donnée)
Mais que je fais ça :
Code:
1 2 3 4 5 6 7 8 9 10
|
$this->form = new sfForm();
$this->form->setWidgets(array(
'author' => new sfWidgetFormSelect(array('choices'=>array('PMP')))
));
$this->form->setValidators(array(
'author' => new sfValidatorString()
));
$this->form->getWidgetSchema()->setNameFormat('photo[%s]'); |
ça ne marche pas lorsque je sélectionne l'unique choix que j'ai. Pourtant il s'agit normalement de "PMP" tout comme dans le premier cas.
L'erreur est :
Integrity constraint violation: 1452 Cannot add or update a child row: a foreign key constraint fails (`optd3_phototheque`.`picture`, CONSTRAINT `picture_ibfk_2` FOREIGN KEY (`author`) REFERENCES `person` (`id`) ON DELETE NO ACTION ON UPDATE CASCADE)
(En fait, j'utilise symfony 1.4)
Merci d'avance