Dynamic fields on insert/edit form
let's say that i have 3 tables:
- books
- properties
- book_properties
of course, i would like that when i want to insert new book (or update existing), to fill the form.
fields that exist on form have to be defined as records in table properties.
when i fill up those fields, data has to be saved in table book_p开发者_JS百科roperties.
can you help me by giving some advices and references, how to achieve that?
thank you very much in advance!
You will need to create 3 tables: books (id, author, title, etc.), properties (id, name) and books_properties (id, book_id, property_id, property_value). Notice that the third table must be named books_properties, not book_property. Then you will need to create models for the books and properties tables. See the manual here. Create correct assosiations. Books HasAndBelongsToMany Properties. If you use cake console it will be easier to create models, controllers and views.
精彩评论