Can you show me the schema?
Maybe something its incorrect in the relations.





2009/10/10 Dennis <[email protected]>

>
> Let's say you have a schema of:
>
> 'User'
> 'MovingBoxForBooks'
> 'Book'.
>
> 'User'->1-to-many->'MovingBoxForBooks'
> 'MovingBoxForBooks'->1-to-many->'Book'
>
> 'User' is a parent of 'MovingBoxForBooks'
> 'MovingBoxForBooks' is a CHILD of 'User'
>
> 'MovingBoxForBooks' is a parent of 'Book'
> 'Book' is a CHILD of 'MovingBoxForBooks'
>
> If you use the default CRUD generator and scaffolding, (which I am
> beginning to believe that more advanced Symfony users don't use after
> awhile), and go to the 'MovingBoxForBooks' form, you will find a drop
> down list for 'User'. It will probably have a title like, "No value
> available for User". (You need to define the __toString() method).
> That is the PARENT showing up in the CHILD form.
>
> BUT you will NOT see any form fields for 'Book' in the
> 'MovingBoxForBooks' form, NO CHILDREN form fields show up
> automagically.
>
> Does this clear it up?
>
> On Oct 9, 12:42 am, elkrema <[email protected]> wrote:
> > Hi Dennis,
> >
> > thank you for your comments.
> >
> > About your problem adding a Children to the Parent Object, i don't
> > understand it very well.
> >
> > I just take a look to your link about but i think it's more or less
> > like im doing? Adding some embeds , right?
> >
> > Can you explain me more?
> >
> > Thank you.
> >
> > On 7 oct, 01:24, Dennis <[email protected]> wrote:
> >
> >
> >
> > > Try this for adding an object's PARENT form to the child form.
> http://www.symfony-project.org/blog/2008/11/07/new-in-symfony-1-2-doc...
> >
> > > Where it says "Edit/Add Author" Exactly in the middle of the document.
> >
> > > Me, I'm looking to add Chidren to the Parent Object, but not a large
> > > quanity of them like this guy did:
> http://www.thatsquality.com/articles/can-the-symfony-forms-framework-...
> >
> > > Also, he had to go to a lot of trouble to get it to work.
> >
> > > There's got to be a way to add the children, or a blank one without
> > > going to the trouble that he went tol.
> >
> > > (doctrine btw)
> > > ParticularForm extends BaseParticularForm{
> >
> > > function configuration(){
> > >   $this->getObject()->getRelatedObjectForm
> >
> > > On Oct 5, 11:20 pm, Francisco José Núñez Rivera <[email protected]>
> > > wrote:
> >
> > > > I tried it with
> >
> > > > $opinion = new Opinion();
> > > > $opfeat = new $opinion->OpinionFeature;
> >
> > > > but cant find the class OpinionFeature...
> >
> > > > Otherwise i do the same you write (more or less). I think that when
> i'm
> > > > showing opinion form it creates a new Opinion(); variable.
> > > > Then i use that variable to set the new OpinionFeature var...
> > > > $opfeat->setOpinionId($this->getObject()->id);
> > > > $opfeat->setFeatureId($feature->getId());
> >
> > > > $OFform = new OpinionFeatureForm($opfeat);
> > > > $this->embedForm('feature_'.$feature->getId(), $OFform);
> >
> > > > But it doesnt work... i have to overwrite saveEmbedForms....
> >
> > > > public function saveEmbeddedForms($con = null, $forms = null)
> > > >   {
> >
> > > >         foreach($this->getEmbeddedForms() as $opinionForm)
> > > >         {
> >
> > > > $opinionForm->getObject()->setOpinionId($this->getObject()->getId());
> > > >         }
> >
> > > >     parent::saveEmbeddedForms($con, $forms);
> > > >   }
> >
> > > > I think there's a easier way to do this but.. i dont know. :(
> >
> > > > 2009/10/6 Dennis <[email protected]>
> >
> > > > > I got this off of a Fabien post, somewhere. If you look at it, it
> > > > > makes everything connect to the same parent record. It SHOULD save
> > > > > correctly. I am goin to try it in my project tonight. Let me know
> if
> > > > > it works for you.
> >
> > > > > $user = new User();
> > > > > $profile = new $user->Profile;
> > > > > $userForm = new UserForm($user);
> > > > > $profileForm = new ProfileForm($profile);
> > > > > $userForm->embedForm('Profile', $profileForm);
> >
> > > > > On Oct 5, 2:13 am, elkrema <[email protected]> wrote:
> > > > > > Hi Dennis,
> >
> > > > > > there is my schema:
> >
> > > > > > Feature:
> > > > > >   tableName: feature
> > > > > >   columns:
> > > > > >     id:
> > > > > >       type: integer(8)
> > > > > >       primary: true
> > > > > >       autoincrement: true
> > > > > >     name:
> > > > > >       type: string(255)
> > > > > >       notnull: true
> > > > > >     created_at: timestamp(25)
> > > > > >     updated_at: timestamp(25)
> > > > > >   relations:
> > > > > >     OpinionFeature:
> > > > > >       local: id
> > > > > >       foreign: feature_id
> > > > > >       type: many
> >
> > > > > > Opinion:
> > > > > >   tableName: opinion
> > > > > >   columns:
> > > > > >     id:
> > > > > >       type: integer(8)
> > > > > >       primary: true
> > > > > >       autoincrement: true
> > > > > >     title:
> > > > > >       type: string(255)
> > > > > >       notnull: true
> > > > > >     opiniontxt:
> > > > > >       type: string(2147483647)
> > > > > >       notnull: true
> > > > > >     is_active:
> > > > > >       type: integer(1)
> > > > > >       default: '0'
> > > > > >       notnull: true
> > > > > >     token:
> > > > > >       type: string(255)
> > > > > >       notnull: true
> > > > > >     created_at: timestamp(25)
> > > > > >     updated_at: timestamp(25)
> > > > > >   relations:
> > > > > >     OpinionFeature:
> > > > > >       local: id
> > > > > >       foreign: opinion_id
> > > > > >       type: many
> >
> > > > > > OpinionFeature:
> > > > > >   tableName: opinion_feature
> > > > > >   columns:
> > > > > >     opinion_id:
> > > > > >       type: integer(8)
> > > > > >       primary: true
> > > > > >     feature_id:
> > > > > >       type: integer(8)
> > > > > >       primary: true
> > > > > >     score:
> > > > > >       type: float(2147483647)
> > > > > >       notnull: true
> > > > > >     created_at: timestamp(25)
> > > > > >     updated_at: timestamp(25)
> > > > > >   relations:
> > > > > >     Opinion:
> > > > > >       local: opinion_id
> > > > > >       foreign: id
> > > > > >       type: one
> > > > > >     Feature:
> > > > > >       local: feature_id
> > > > > >       foreign: id
> > > > > >       type: one
> >
> > > > > > Its very similar to your schema. Mine havent got foreign_type but
> i
> > > > > > think it works same yours... no?
> >
> > > > > > I did that with mysql workbench and then build schema... :)
> >
> > > > > > I think the problem was save embed forms i have to overwrite the
> > > > > > saveEmbedForms function to set the opinionid of the
> OpinionFeature
> > > > > > just at the moment of insert the opinion. Doing that it works,
> but i
> > > > > > dont know if its the right way.
> >
> > > > > > Thank you very much.
> >
> > > > > > On 5 oct, 05:10, Dennis <[email protected]> wrote:
> >
> > > > > > > So what you have is a:
> >
> > > > > > > <Opinion>--1-to-many --<OpinionFeature>--many-to-1--<Feature>
> >
> > > > > > > (above is a good way to show a schema)
> >
> > > > > > > So you have to set up your schema to reflect that:
> >
> > > > > > > Keep in mind that you have to create the Parents, before
> creating the
> > > > > > > children.
> > > > > > > Parents HAVE an ID, Children are GIVEN or USE and ID.
> >
> > > > > > > Parents are 'Opinion' and 'Feature'.
> >
> > > > > > > Opinion:
> > > > > > >   tableName: opinion
> > > > > > >   columns:
> > > > > > >     opinion_id:
> > > > > > >       type: integer(8)
> > > > > > >       primary: true
> > > > > > >       sequence: opinion_opinion_id
> > > > > > >     opinion_name:
> > > > > > >       type: string(65)
> > > > > > >       notnull: true
> > > > > > >   relations:
> > > > > > >     OpinionFeature:
> > > > > > >       local: opinion_id
> > > > > > >       foreign: opinion_id
> > > > > > >       type: many
> > > > > > >       foreignType: one
> >
> > > > > > > Feature:
> > > > > > >   tableName: feature
> > > > > > >   columns:
> > > > > > >     feature_id:
> > > > > > >       type: integer(8)
> > > > > > >       primary: true
> > > > > > >       sequence: feature_feature_id
> > > > > > >     feature_name:
> > > > > > >       type: string(32)
> > > > > > >       notnull: true
> > > > > > >     feature_desc:
> > > > > > >       type: string(128)
> > > > > > >       notnull: true
> > > > > > >   relations:
> > > > > > >     OpinionFeature:
> > > > > > >       local: feature_id
> > > > > > >       foreign: feature_id
> > > > > > >       type: many
> > > > > > >       foreignType: one
> >
> > > > > > > OpinionFeature:
> > > > > > >   tableName: opinionfeature
> > > > > > >   columns:
> > > > > > >     opinion_id:
> > > > > > >       type: integer(8)
> > > > > > >       primary: true
> > > > > > >     feature_id:
> > > > > > >       type: integer(8)
> > > > > > >       primary: true
> > > > > > >     score:
> > > > > > >       type: integer(2)
> > > > > > >       notnull: true
> > > > > > >   relations:
> > > > > > >     Opinion:
> > > > > > >       local: opinion_id
> > > > > > >       foreign: opinion_id
> > > > > > >       type: one
> > > > > > >       foreignType: many
> > > > > > >     Feature:
> > > > > > >       local: feature_id
> > > > > > >       foreign: feature_id
> > > > > > >       type: one
> > > > > > >       foreignType: many
> >
> > > > > > >  See if this works :-)
> >
> > > > > > > Personally, I like graphical database design tools. I make the
> design,
> > > > > > > have it spit out the code for the database that I'm using, then
> make
> > > > > > > the database, use Doctrine to build the schema (instead of
> composing
> > > > > > > it like above), make my model-forms-filters, and go.
> >
> > > > > > > I've had good luck using DezignForDatabases. The guy who makes
> it is
> > > > > > > very helpful and friendly. It's not perfect, but it's great for
> the
> > > > > > > price.
> > > > > > > On Oct 2, 3:39 am, Francisco José Núñez Rivera <
> [email protected]>
> > > > > > > wrote:
> >
> > > > > > > > But all the opinions have the same features.
> >
> > > > > > > > Feature -> id , desc
> > > > > > > > 1,Feature 1 ; 2, Feature2...
> >
> > > > > > > > Opinion shows all the features..
> > > > > > > > Feature 1 -Score:
> > > > > > > > Feature 2 - Score:
> >
> > > > > > > > OpinionFeature -> opinion_id , feature_id , score
> > > > > > > > I only insert a row here when im scoring a feature.
> >
> > > > > > > > I think my schema is right... no?
> >
> > > > > > > > Thank you very much.
> >
> > > > > > > > 2009/10/1 Abraham Montilla <[email protected]>
> >
> > > > > > > > > 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
> >
> > ...
> >
> > read more »- Hide quoted text -
> >
> > - Show quoted text -
> >
>

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