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

michele.gherlone at liceoberchet.it michele.gherlone at liceoberchet.it
Wed Aug 5 01:06:06 GMT 2009


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





More information about the HTML-FormFu mailing list