We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 44580
    • 189 Posts
    I'm using MigxLoopCollection to populate a listbox on a Migx Formtab. There are 4 rows in the table (term_calendar) and only the last two are being returned (there is no where clause). I cannot be 100% certain, but I think this has only started happening since I upgraded to the latest version of Migx (2.9.0).

    Regardless, this is my configuration:

    Schema (partial)

    	<object class="Invoice" table="invoice" extends="xPDOSimpleObject">
    		<field key="user_id" dbtype="int" precision="11" phptype="integer" null="false" />
    		<field key="term_id" dbtype="int" precision="11" phptype="integer" null="false" />
    		<field key="invoice_date" dbtype="date" phptype="date" null="false" />
    		<field key="payments" dbtype="decimal" precision="10,2" phptype="float" null="false" />
    		<field key="balance" dbtype="decimal" precision="10,2" phptype="float" null="false" />
    		<field key="due_date" dbtype="date" phptype="date" null="false" />
    		<field key="date_sent" dbtype="date" phptype="date" null="false" />
    		<field key="num_times_sent" dbtype="int" precision="11" phptype="integer" null="false" />
    		<field key="status_text" dbtype="varchar" precision="20" phptype="string" null="false" />
    		<field key="is_paid" dbtype="tinyint" precision="4" phptype="integer" null="false" />
    		<field key="is_overdue" dbtype="tinyint" precision="4" phptype="integer" null="false" />
    		<field key="payment_submitted_date" dbtype="int" precision="11" phptype="integer" null="false" />
    		<field key="is_payment_completed" dbtype="tinyint" precision="4" phptype="integer" null="false" />
                    <composite alias="InvoiceLines" class="InvoiceLines" local="id" foreign="invoice_id" cardinality="many" owner="local" />
                    <aggregate alias="InvProfile" class="modUserProfile" local="user_id" foreign="internalKey" cardinality="one" owner="foreign" />
    	</object>
    	<object class="TermCalendar" table="term_calendar" extends="xPDOSimpleObject">
    		<field key="from_date" dbtype="date" phptype="date" null="false" />
    		<field key="to_date" dbtype="date" phptype="date" null="false" />
    		<field key="term" dbtype="tinyint" precision="4" phptype="integer" null="false" />
    		<field key="term_year" dbtype="year" precision="4" phptype="string" null="true" />
    	</object>


    Formtab definition (see id:59)
    {
      "formtabs":[
        {
          "MIGX_id":12,
          "caption":"Invoice Header",
          "print_before_tabs":"0",
          "fields":[
            {
              "MIGX_id":58,
              "field":"user_id",
              "caption":"Name",
              "description":"",
              "description_is_code":"0",
              "inputTV":"",
              "inputTVtype":"listbox",
              "validation":"",
              "configs":"",
              "restrictive_condition":"",
              "display":"",
              "sourceFrom":"config",
              "sources":"",
              "inputOptionValues":"@CHUNK getParentList",
              "default":"",
              "pos":1
            },
            {
              "MIGX_id":59,
              "field":"term_id",
              "caption":"Term",
              "description":"",
              "description_is_code":"0",
              "inputTV":"",
              "inputTVtype":"listbox",
              "validation":"",
              "configs":"",
              "restrictive_condition":"",
              "display":"",
              "sourceFrom":"config",
              "sources":"",
              "inputOptionValues":"@CHUNK getTermList",
              "default":"",
              "useDefaultIfEmpty":"0",
              "pos":2
            },
            {
              "MIGX_id":69,
              "field":"invoice_date",
              "caption":"Invoice Date",
              "description":"",
              "description_is_code":"0",
              "inputTV":"",
              "inputTVtype":"date",
              "validation":"",
              "configs":"",
              "restrictive_condition":"",
              "display":"",
              "sourceFrom":"config",
              "sources":"",
              "inputOptionValues":"",
              "default":"",
              "pos":3
            }
          ],
          "pos":1
        },
        {
          "MIGX_id":13,
          "caption":"Invoice Lines",
          "print_before_tabs":"0",
          "fields":[
            {
              "MIGX_id":66,
              "field":"InvoiceLines",
              "caption":"Invoice lines",
              "description":"",
              "description_is_code":"0",
              "inputTV":"",
              "inputTVtype":"migxdb",
              "validation":"",
              "configs":"InvoiceLines",
              "restrictive_condition":"",
              "display":"",
              "sourceFrom":"config",
              "sources":"",
              "inputOptionValues":"",
              "default":"",
              "pos":1
            }
          ],
          "pos":2
        }
      ],
      "contextmenus":"update||remove",
      "actionbuttons":"addItem||createinvoices||sendinvoices",
      "columnbuttons":"update||remove",
      "filters":"",
      "extended":{
        "migx_add":"New Invoice",
        "disable_add_item":"",
        "add_items_directly":"",
        "formcaption":"Create Invoices",
        "update_win_title":"Create Invoices",
        "win_id":"CreateInvoices",
        "maxRecords":"",
        "addNewItemAt":"bottom",
        "multiple_formtabs":"",
        "multiple_formtabs_label":"",
        "multiple_formtabs_field":"",
        "multiple_formtabs_optionstext":"",
        "multiple_formtabs_optionsvalue":"",
        "actionbuttonsperrow":4,
        "winbuttonslist":"",
        "extrahandlers":"",
        "filtersperrow":4,
        "packageName":"add",
        "classname":"Invoice",
        "task":"",
        "getlistsort":"",
        "getlistsortdir":"",
        "sortconfig":"",
        "gridpagesize":"",
        "use_custom_prefix":1,
        "prefix":"add_",
        "grid":"",
        "gridload_mode":1,
        "check_resid":1,
        "check_resid_TV":"",
        "join_alias":"",
        "has_jointable":"yes",
        "getlistwhere":"",
        "joins":[
          {
            "alias":"Profilep",
            "classname":"modUserProfile",
            "on":"Profilep.internalKey=Invoice.user_id"
          },
          {
            "alias":"Termdesc",
            "classname":"TermCalendar",
            "on":"Termdesc.id=Invoice.term_id"
          }
        ],
        "cmpmaincaption":"Create Invoices",
        "cmptabcaption":"Create Invoices",
        "cmptabdescription":"Generate Invoices for review and delivery",
        "cmptabcontroller":"",
        "winbuttons":"",
        "onsubmitsuccess":"",
        "submitparams":""
      },
      "columns":[
        {
          "MIGX_id":1,
          "header":"Inv. No.",
          "dataIndex":"id",
          "width":12,
          "sortable":"false",
          "show_in_grid":1,
          "renderer":"",
          "clickaction":"",
          "selectorconfig":"",
          "renderchunktpl":"",
          "renderoptions":""
        },
        {
          "MIGX_id":2,
          "header":"Name",
          "dataIndex":"Profilep_fullname",
          "width":40,
          "sortable":"false",
          "show_in_grid":1,
          "renderer":"",
          "clickaction":"",
          "selectorconfig":"",
          "renderchunktpl":"",
          "renderoptions":""
        },
        {
          "MIGX_id":4,
          "header":"Invoice total",
          "dataIndex":"balance",
          "width":16,
          "sortable":"false",
          "show_in_grid":1,
          "renderer":"",
          "clickaction":"",
          "selectorconfig":"",
          "renderchunktpl":"",
          "renderoptions":""
        },
        {
          "MIGX_id":5,
          "header":"Term",
          "dataIndex":"Termdesc_year",
          "width":15,
          "sortable":"false",
          "show_in_grid":1,
          "renderer":"this.renderChunk",
          "clickaction":"",
          "selectorconfig":"",
          "renderchunktpl":"Term [[+Termdesc_term]], [[+Termdesc_term_year]]",
          "renderoptions":""
        },
        {
          "MIGX_id":3,
          "header":"Date",
          "dataIndex":"invoice_date",
          "width":20,
          "sortable":"false",
          "show_in_grid":1,
          "renderer":"",
          "clickaction":"",
          "selectorconfig":"",
          "renderchunktpl":"",
          "renderoptions":""
        }
      ]
    }


    getTermList Chunk code
    [[migxLoopCollection?
    &packageName=`add`
    &prefix=`add_`
    &classname=`TermCalendar`
    &tpl=`@CODE:Term [[+term]], [[+term_year]]==[[+id]]`
    &outputSeparator=`||`
    ]]
    


    What am I missing please?
      • 4172
      • 5,888 Posts
      put this into a template or content of a resource.

      [[migxLoopCollection?
      &packageName=`add`
      &prefix=`add_`
      &classname=`TermCalendar`
      &debug = `1`
      ]]


      what do you get?
        -------------------------------

        you can buy me a beer, if you like MIGX

        http://webcmsolutions.de/migx.html

        Thanks!
        • 44580
        • 189 Posts
        Thanks Bruno.

        This is what I get:
        SELECT `TermCalendar`.`from_date`, `TermCalendar`.`to_date`, `TermCalendar`.`term`, `TermCalendar`.`term_year` FROM `add_term_calendar` AS `TermCalendar`
        
        Array
        (
            [from_date] => 2015-10-05
            [to_date] => 2015-12-18
            [term] => 4
            [term_year] => 2015
            [_alt] => 1
            [_first] => 
            [_last] => 1
            [idx] => 4
            [property.packageName] => add
            [property.prefix] => add_
            [property.classname] => TermCalendar
            [property.debug] => 1
        )
        

        and just to prove that there are 4 rows:
        mysql> select * from add_term_calendar;
        +----+------------+------------+------+-----------+
        | id | from_date  | to_date    | term | term_year |
        +----+------------+------------+------+-----------+
        |  7 | 2015-01-28 | 2015-03-27 |    1 |      2015 |
        |  8 | 2015-04-13 | 2015-06-26 |    2 |      2015 |
        |  9 | 2015-07-13 | 2015-09-18 |    3 |      2015 |
        | 10 | 2015-10-05 | 2015-12-18 |    4 |      2015 |
        +----+------------+------------+------+-----------+
        4 rows in set (0.00 sec)
        
          • 4172
          • 5,888 Posts
          are you getting only one array, here?
          Have no idea, why this should happen.

          Do you have some custom-code in your TermCalendar-class?
            -------------------------------

            you can buy me a beer, if you like MIGX

            http://webcmsolutions.de/migx.html

            Thanks!
            • 44580
            • 189 Posts
            What's really weird is that in the listbox I am actually getting 2 values - for term 3 and term 4. This table is only used to generate the "easy to read" values for the listbox - I have no custom code. Previously, I was sure I was getting all 4 in the listbox.

            The only other thing that I have changed recently is to add some aggregate keys to try and extend Moduser, which includes the Invoice table. In fact this is not working either( see https://forums.modx.com/thread/95792/i-just-want-to-delete-child-records?)

            It's late here - unless you have any further suggestions, tomorrow I will remove the aggregate key and see if that makes any difference - although why it should...

            Thanks Bruno.
              • 44580
              • 189 Posts
              As suspected, removing the aggregate key made no difference. Double checked the TermCalendar class - no custom code. Where to next Bruno?