try just unsetting opinion_id, tell me if works
2009/9/29 elkrema <[email protected]>
>
> Hello Abraham,
>
> This is my code with i'm embedding forms in OpinionForm:
>
> foreach($this->getObject()->getFeatures() as $feature)
> {
> $opinionf = new OpinionFeature();
> $opinionf->setOpinionId($this->getObject()->id);
> $opinionf->setFeatureId($feature->getId());
> $this->embedForm($feature->getName(), new OpinionFeatureForm
> ($opinionf));
> }
>
> With this code in when saving always get this flash message in the
> first Feature...
>
> * Feature id: Invalid.
>
> And if i configure OpinionFeatureForm to unset the fields (just for
> testing)
>
> unset($this['opinion_id'], $this['feature_id']);
>
> I get ..
>
> SQLSTATE[23000]: Integrity constraint violation: 1452 Cannot add or
> update a child row: a foreign key constraint fails
> (`opinion`.`opinion_feature`, CONSTRAINT `opinion_feature_ibfk_1`
> FOREIGN KEY (`opinion_id`) REFERENCES `opinion` (`id`) ON DELETE
> CASCADE)
>
> Thank you for helping
>
>
>
>
>
> On 29 sep, 01:25, Abraham Montilla <[email protected]> wrote:
> > i think it's because when embedding the OpinionFeatureForms you're not
> > setting properly the foreign key to the objects, would be something like
> >
> > for ( $i ..... ){
> > $opfeat = new OpinionFeature();
> > $opfeat->setOpinionId($this->getObject->getId());
> > $OFform = new OpinionFeatureForm($opfeat);
> > $this->embedForm('Feature_'.$i, $OFform);
> >
> > }
> >
> > 2009/9/28 elkrema <[email protected]>
> >
> >
> >
> >
> >
> > > Hello
> >
> > > i have some problems with my embed forms and i can't find a
> > > solution...
> >
> > > I have an Opinion with many Features..
> >
> > > Feature is: id, desc
> > > OpinionFeature is: opinion_id, feature_id,score
> >
> > > In OpinionForm i'm inserting with [for each] all the features, but
> > > when im creating a new opinion i always get [Integrity constraint
> > > violation]
> >
> > > I'ts easy get the id of the feature but i can get the ID of the
> > > opinion because it isnt created yet... is null.
> >
> > > Somebody can help me please? I get trought many forums and jobeet
> > > tutorial but i cant get the solution!
> >
> > > PS. Sorry for me english!!
> >
> > --
> > Have a nice day.
> > Abraham Montilla.
> >
>
--
Have a nice day.
Abraham Montilla.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"symfony users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/symfony-users?hl=en
-~----------~----~----~----~------~----~------~--~---