Search code examples
formssymfony-1.4propel

Form in Form. Symfony


I use Symfony1.4 and Propel my application. I have a problem. For example: I have a database in which I want to keep authors and books. I make the following scheme: schema.yml

book:
    id: ~
    name: {type: varchar (100), required: true}

author:
    id: ~
    name: {type: varchar (100), required: true}

author_book:
    id_book: {type: integer, foreignTable: book, foreignReference: id, required: true, primaryKey: true, onDelete: cascade}
    id_author: {type: integer, foreignTable: author, foreignReference: id, required: true, primaryKey: true, onDelete: cascade}

And I want to with the addition of the author, add books that he wrote, without leaving the page for adding the author. This is an easy question, but for some reason I have not found the solution. (I think do this by writing a widget that using ajax to load the form of "adding a book", but is not it possible there is a ready solution?)


Solution

  • You can use sfForm::embedForm() to embed several form. Look at this doc : http://symfony.com/legacy/doc/more-with-symfony/1_4/en/06-Advanced-Forms, it is explained.