[html-formfu] re: Confusion with options_from_model and many_to_many

Ascii King tech at swattermatter.com
Wed May 27 19:25:27 GMT 2009


I get similair problems, Toby. One thing you can check is to see if your 
select box is inside a repeatable element. The select and the repeatable 
don't like each other too much, so maybe it's the same with Checkboxgroup.

A big problem I find with the documentation is the fact that everything 
has the same name. The Book table has a book field and a relationship 
called book. It just makes it so I can't tell what's supposed to go where.

Toby Corkindale wrote:
> 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
>
> _______________________________________________
> HTML-FormFu mailing list
> HTML-FormFu at lists.scsys.co.uk
> http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/html-formfu
>



More information about the HTML-FormFu mailing list