[html-formfu] re: Confusion with options_from_model and many_to_many
Toby Corkindale
toby.corkindale at strategicdata.com.au
Tue May 26 07:41:58 GMT 2009
Hi,
I've just joined the list, but wondered if anyone, including Leanan,
resolved the issue in their email from March:
http://lists.scsys.co.uk/pipermail/html-formfu/2009-March/001852.html
I just ask because I seem to be having the identical problem..
I have a classic many-to-many relationship, but can't get this to work
as per the documentation.
Example:
table books (id, title)
.. ->has_many(book_genres => 'BookGenres', 'book')
.. ->man_to_many(genres => 'book_genres', 'genre')
table genres (id, name)
.. ->has_many(book_genres => 'BookGenres', 'genre')
.. ->many_to_many(books => 'book_genres', 'book')
table book_genres (book, genre);
.. ->belongs_to(book => books)
.. ->belongs_to(genre => genres)
So the formfu definition for a book should be:
elements:
- name: title
type: Text
- type: Checkboxgroup
name: genres
However in practice that doesn't work.. After some experimentation, I
ended up with the following:
elements:
- name: title
type: Text
- type: Checkboxgroup
name: genres
model_config:
default_column: 'me.id'
resultset: Genres
This at least renders the form, and populates the options that are
available. However the current options are not pre-set, nor are changes
saved to the database.
I'm probably doing something wrong, but wondered if you could help me
figure out what! I've been banging my head against this for ages.
Thanks,
Toby
More information about the HTML-FormFu
mailing list