elkrema, if you have I have an Opinion with many Features then the right
schema is

Feature is: id, opinion_id, desc
OpinionFeature is: opinion_id, score

that's why you have an integrity constraint violation.... I don't know how i
missed that first time i read your post hehe, that's all the problem

2009/10/1 elkrema <[email protected]>

>
> With unsetting only option id doesn't work.
>
> The problem is that i am inserting the object of main form and the
> embedded objects too.
>
> But i found a solution... I rewrite the function saveEmbeddedForms in
> OpinionForm
>
>  public function saveEmbeddedForms($con = null, $forms = null)
>  {
>
>                foreach($this->getEmbeddedForms() as $opinionForm)
>                {
>
>  $opinionForm->getObject()->setOpinionId($this->getObject()->getId
> ());
>                }
>
>
>        parent::saveEmbeddedForms($con, $forms);
>  }
>
> I set the opinionid before saving the embed forms....I dont know if is
> the good way..
>
> Otherwise i have a new problem..
>
> when i'm editing an opinion the value of the last feature is not
> showed.. ¿?
>
> Thank you!
>
>
>
>
>
>
> On 30 sep, 07:21, Abraham Montilla <[email protected]> wrote:
> > 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.
> >
>


-- 
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to