Ticket #581 (closed enhancement: fixed)

Opened 3 months ago

Last modified 3 months ago

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

Reported by: bibo Assigned to: bibo
Priority: normal Milestone: Jelix 1.1 beta 1
Component: jelix:forms Version: trunk
Severity: normal Keywords:
Cc: Php version:
Review: review+ Hosting Provider:
Documentation needed: 0 Blocking:

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

jelix-trunk-#xxx.patch (4.6 kB) - added by bibo on 05/16/08 14:47:34.
rapid patch
jelix-trunk-#581.patch (5.7 kB) - added by bibo on 05/29/08 12:28:23.
updated on laurentj comments.

Change History

05/16/08 14:47:34 changed by bibo

  • attachment jelix-trunk-#xxx.patch added.

rapid patch

05/20/08 18:12:11 changed by laurentj

  • review set to review?.

05/28/08 10:48:33 changed by laurentj

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

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.

05/29/08 12:28:23 changed by bibo

  • attachment jelix-trunk-#581.patch added.

updated on laurentj comments.

05/29/08 12:30:50 changed 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.

05/29/08 13:39:47 changed by bibo

  • review changed from review- to review?.

05/31/08 00:35:26 changed 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 ;-)

05/31/08 23:38:20 changed by bibo

  • status changed from assigned to closed.
  • resolution set to fixed.

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.

Download in other formats: Comma-delimited Text Tab-delimited Text RSS Feed