developer.jelix.org is not used any more and exists only for history. Post new tickets on the Github account.
developer.jelix.org n'est plus utilisée, et existe uniquement pour son historique. Postez les nouveaux tickets sur le compte github.

Opened 13 years ago

Closed 12 years ago

Last modified 12 years ago

#581 closed enhancement (fixed)

jForms : specify more than one labelProperty and criteriaFrom for dao datasource

Reported by: bibo Owned by: bibo
Priority: normal Milestone: Jelix 1.1 beta 1
Component: jelix:forms Version: trunk
Severity: normal Keywords:
Cc: Blocked By:
Blocking: Documentation needed: no
Hosting Provider: Php version:

Description

One should be able to specify more than one criteriaFrom to select data. On the label side, One should be able to concatenate more than one labelProperty.

the purest solution would be to modify relaxNg form definition. criteriaFrom and labelProperty should become elements child of datasource. But I had no time to do that and it adds complexity to the datasource element.

so I hacked jFormsDaoDatasource and jFormsCompiler1_1 to support this :

      <datasource dao="module~dao" method="mymethod" criteriafrom="array('crit1','crit2')"
                  labelproperty="array('prop1','prop2','separator')" />

perhaps the use of array() is too literal and implies ugly mod in compiler. little patch attached. thoughts ?

Attachments (2)

jelix-trunk-#xxx.patch (4.6 KB) - added by bibo 13 years ago.
rapid patch
jelix-trunk-#581.patch (5.7 KB) - added by bibo 13 years ago.
updated on laurentj comments.

Download all attachments as: .zip

Change History (11)

Changed 13 years ago by bibo

rapid patch

comment:1 Changed 13 years ago by laurentj

  • review set to review?

comment:2 Changed 13 years ago by laurentj

  • Milestone set to Jelix 1.1 beta 1
  • review changed from review? to review-

I prefer this:

<datasource dao="module~dao" method="mymethod" criteriafrom="crit1,crit2"
                  labelproperty="prop1,prop2" labelseparator=""/>

So we have a specific attribute for the separator (so no confusion with labels name), and you just have to split to have the list of criterias or labels, by using preg_split:

preg_split("/[\s,]+/",...

I think it is not necessary to use the & here (we are in php5, objects are always given by reference)

$found = call_user_func_array( array( $this->dao, $this->method), $args); 

You forgot also to declare the $separator property.

Changed 13 years ago by bibo

updated on laurentj comments.

comment:3 Changed 13 years ago by bibo

  • Owner set to bibo
  • Status changed from new to assigned

new patch updated according to laurentj comments. tested with testapp and my own app.

comment:4 Changed 13 years ago by bibo

  • review changed from review- to review?

comment:5 Changed 12 years ago by laurentj

  • review changed from review? to review+

ok. Just put the $labelSeparator= at the end of the list of parameters of the constructor. Don't forget to update and launch unit tests ;-)

comment:6 Changed 12 years ago by bibo

  • Resolution set to fixed
  • Status changed from assigned to closed

Fixed on trunk. We had not talked about criteria attribute, but I felt right to be on par to criteriaFrom. After all they are twins attribute, no ? All unit tests passes, added a bunch of ones.

comment:7 Changed 12 years ago by laurentj

  • Documentation needed set

comment:8 Changed 12 years ago by bibo

Already documented in french

comment:9 Changed 12 years ago by laurentj

  • Documentation needed unset
Note: See TracTickets for help on using tickets.