Sonata Form presentation structure for related parent child

Discuss Symfony 2 bundles here

Moderators: dcobalt, tiagojsag

Sonata Form presentation structure for related parent child

Postby sibok » Sun Jun 17, 2012 2:46 am

i have two related entities Foo and FooI18n which looks like the above ones. Each entity represents a table in the database and as you can see relationship is OneTOMany, so one Foo objects have multiple FooI18nobjects.

Right now i'm working with Sonata in order to create the backoffice administration site, i've created two separated admins - one for each entity - but i don't want force the users to manage each entity separately. I would like to present a whole form where one can add/remove child elements.

Does anyone worked on a use case like that one? Could would you proceed?

PD: On some cases entities relation chain is about 4 or 5 levels, so mean 4 or 5 entities are related between them and would like to find a valid solution for all cases and being able to manage it all as simple as possible. Thanks in advanced!
Code: Select all
Class Foo
{
    /**
     *  @ORM\Id
     *  @ORM\Column( type="integer", length="4" )
     *  @ORM\GeneratedValue( strategy="AUTO" )
     */
    private $id;
    /** @ORM\OneToMany( targetEntity="FooI18n", mappedBy="foo" ) */
    private $childs;
}

Class FooI18n
{
   /**
    *  @ORM\Id
    *  @ORM\Column(type="integer", length="4", name="id")
    *  @ORM\GeneratedValue(strategy="AUTO")
    */
    private $id;

    /**
     *  @ORM\ManyToOne( targetEntity="Foo", inversedBy="childs" )
     *  @ORM\JoinColumn( name="foo_id", nullable=false, referencedColumnName="id", onDelete="CASCADE" )
     */
    private $foo;
    /**
     * @ORM\Column( type="text", nullable=false, unique=false, name="content" )
     */
    private $content;
sibok
Junior Member
 
Posts: 8
Joined: Mon Jun 04, 2012 11:25 am

Return to Bundles discussion

Who is online

Users browsing this forum: No registered users and 2 guests