[html-formfu] How to restrict retrieved rows in has_many relationships?

Mario Minati mario.minati at googlemail.com
Wed Aug 5 05:34:58 GMT 2009


Hi Michele,

currently I don't think this is possible in the dynamic way you want it.

What I don't understand is that materia is a underneath voti. If materia 
shall control the elements of voti, it should be at least on the same 
hierarchical level.

To achieve your goal, we would need to extend FormFu::Model::DBI to 
handle dynamic parameters.


Greets,

Mario Minati

michele.gherlone at liceoberchet.it schrieb:
> Hi all.
> I've setup the following relationships in my application:
> - table classe has_many studenti
> - table studente has_many voti
> - table voto belongs_to studente, materia
> Now I have created the following table/form in yaml:
>
> ---
> autofield_set: 1
> elements:
>   - type: Hidden
>     name: count
>   - type: Block
>     tag: table
>     attributes:
>       width: 100%
>     elements:
>         - type: Repeatable
>           tag: tr
>           nested_name: studenti
>           counter_name: count
>           elements:
>             - type: Block
>               tag: td
>               elements:
>                 - type: Hidden
>                   name: id
>                 - type: Label
>                   name: cognome
>                 - type: Label
>                   name: nome
>                 - type: Hidden
>                   name: count
>                 - type: Repeatable
>                   nested_name: voti
>                   counter_name: count
>                   tag: td
>                   elements:
>                     - type: Hidden
>                       name: id
>                     - name: voto
>                     - name: data_voto
>                     - type: Block
>                       nested_name: materia
>                       elements:
>                         - name: materia
>
>   - type: Submit
>     name: submit
>     attributes:
>       value: Invia
>
> This works very well. But what I want now to do is to restrict the rows
> which are retrieved by the nested Repeatable 'voti' based on the value of
> 'materia', i.e. I *DON'T* want all the notes for each student, but I want
> only a few of them based upon some search criteria. How can I pass a
> search condition or something similar to the repeatable block? Is this
> possible at all?
> Thanks in advance,
> Michele Gherlone
>
>
>
> _______________________________________________
> 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