We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 48272
    • 24 Posts
    I am fairly new to modx. I have tried to find a solution for myself the past few days and I think that I am missing something.

    I created two lists;
    1) Debtors
    2) User

    I use migx to manage the debtors and the users. I like to have a list of users within a debtor (which is some kind of group).

    I managed to get that working. I have a grid and can Add and Edit users. I created a snippet getUserlist. No problems there. It all seems to work.
    I want to extend the logic with that Snippet. I only want to show the users which are not assigned (for example). And of course the current user id.

    I tried everything; @CHUNK binding, Input Option Values with @EVAL binding, an InputTV. Even a field with Description_is_code.

    It seemed so easy. Entering the following statement in "Input Option Values" in the tab "Input Options" .
    @EVAL return $modx->runSnippet('getUserlist',array("debtorid" => "[[+debtor_id]]","currentuser" => "[[+modx_user_id]]")); 


    (modx_user_id and debtor_id are fields in the database/xPDO-class)

    If I use fixed values (like $modx->runSnippet('getUserlist',array("debtorid" => "2"....) it's Ok. But the placeholders (like [[+debtor_id]]) are not replaced.
    I tried @EVAL return $modx->runSnippet('getUserlist',array("debtorid" => "@CODE [[+debtor_id]]","currentuser" => "[[+modx_user_id]]"));
    No luck there.

    This almost seemed to work. On the tab "Field":

    Description_is_code=YES
    Description:

    [[!getUserlist?
    &debtorid=`[[+debtor_id]]`
    &currentid=`[[+modx_user_id]]`
    ]]
    

    But then I only get a text and no formelement (screenshot).

    I looked at https://forums.modx.com/thread/86375/creating-dynamic-listbox-tv-with-help-of-migx but this was about getResources and I do not how this work on custom tables.
    I also looked at https://forums.modx.com/thread/90099/migxdb-passing-record-property-to-input-option but the solution looks a little bit overwhelming.

    My question is: "Is it possible to access the current “object” with placeholders or API-calls within something like this in migx??"

    Example:
    @EVAL return $modx->runSnippet('getUserlist',array("debtorid" => "[[+debtor_id]]","currentuser" => "[[+modx_user_id]]"));


    Thanks for you help. By the way; I am using modx revo 2.2.14-pl and migx 2.81.

      • 4172
      • 5,888 Posts
      I'm unsure where you have this listbox.
      Is it on a MIGXdb - CMP?

      If it is in a MGXdb - CMP, then you should get the current object_id with

      $_REQUEST['object_id']
      inside your getUserlist - snippet

      Or is it a MIGXdb - grid nested into another MIGXdb ?

      Could you post your whole MIGX - configurations (doing import/export at the MIGX-configuration-grid)
        -------------------------------

        you can buy me a beer, if you like MIGX

        http://webcmsolutions.de/migx.html

        Thanks!
        • 48272
        • 24 Posts
        Thanks Bruno!

        I use this in the MIGXdb-cmp (see attached screenshot).

        $_REQUEST['object_id'] seems to work. I get the ID of the selected record. I can probably get it working by accessing the DB, use the object_id to get the stored values of the record with ID=object_id.
        I suppose it is not possible to access the values of my own properties like "debtor_id" in the CMP-form?!