michele.gherl...@liceoberchet.it schrieb:
michele.gherl...@liceoberchet.it schrieb:
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.

Hi, Mario. I didn't explain my relationships in detail, maybe.
Since table materia has_many voti, and table studente has_many voti, in
the 'voti' table we have studente_id and materia_id. In the config file
I
showed you, I am exploiting in the last Block underneath voti the
belongs_to relationship (voto belongs_to materia, materia_id). The
column
I'd like to restrict my results with would also be materia_id.

I think I could also try to use a multi like a select or a checkboxgroup
with options_from_ model, but again I should then set:
model_config:
 resultset: Voto
 condition:
  materia_id: 2
  studente_id: 2315

This way is not dynamic and even the condition options is only available
for options_from_model method.

Could I set these 2 params using dynamically defined values?

No, thats the problem. Currently Model::DBIC picks just 'all' elements
from the resultset (line 308). To implement some kind of selection at
this point we need to implement the condition attribute. Which way would
you say should a declaration for dynamic attributes look like?

I think something like:

$form->model->default_values($dbic_row, condition(s) => {nested_name =>
'voti', materia_id => $materia_id, ...});

would be pretty useful. Of course in the calling Catalyst controller
$materia_id is the result of some user's selection or whatever.
Is this what you meant, or did you mean perhaps a condition for dynamic
attributes to be implemented directly in the .yml config file?
Yes, we need to implement both ways, as form configuration from config files was the original intention of FormFu.
In this
latter case I'm afraid I don't know yaml well enough to propose something
meaningful at all.
Nevermind. These design decisions were always made in regard with the author of HTML::FormFu. But currently he seems to be on holidays. So I'd say we wait for his two cent. Maybe he has thought this over already.
BTW, how can you access the value of one field from
within the .yml config file? Is that possible? If something like
materia_id.value *IS* possible, then the condition attribute can be
declared inside the .yml file (we add a hidden field materia_id after the
call to default values?).
No sorry, also not possible. Only for constraints we have conditions that look into other values.
What line 308 in DBIC.pm does is just calling the rel name on a dbic_row
with ->all, right?
That should then become: @rows=$dbic->search_related($rel,
materia_id=>$materia_id, ...)->all;
Exactly. We need to build in some kind of search at that place, which takes the value from some other place, which might be quite tricky.


Greets,

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


Greets,

Mario Minati

michele.gherl...@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:

---
auto_fieldset: 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@lists.scsys.co.uk
http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/html-formfu


_______________________________________________
HTML-FormFu mailing list
HTML-FormFu@lists.scsys.co.uk
http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/html-formfu



_______________________________________________
HTML-FormFu mailing list
HTML-FormFu@lists.scsys.co.uk
http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/html-formfu

_______________________________________________
HTML-FormFu mailing list
HTML-FormFu@lists.scsys.co.uk
http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/html-formfu




_______________________________________________
HTML-FormFu mailing list
HTML-FormFu@lists.scsys.co.uk
http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/html-formfu


_______________________________________________
HTML-FormFu mailing list
HTML-FormFu@lists.scsys.co.uk
http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/html-formfu

Reply via email to