We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 37143
    • 74 Posts
    Hi, so I have a TV named Notes, with some nested migx TV populating it with fields note and author. So basically, in a record, we can add multiple notes to the Notes TV.

    On my CMP page, grid looks fine.

    Now I'm trying to get the author field to simply default to the current manager user, but I'm not having any luck. Basically, I want that field author to appear in the Columns, but I'll hide it in the formtabs, since it will just default to whichever manager user is entering the note.

    http://stackoverflow.com/questions/27428611/setting-default-value-to-user-extended-field-in-modx- which describes a similar request (except i don't need to get an extended field, just the username)

    I saw from this post above -- that this default value gets determined during rendering of the tv...

    I have a snippet working [[GetUser? &userId=`[[*createdby]]`]] that works fine in a page, but in my CMP this is another matter that I can't wrap my head around. I've tried @EVALs, but they seem to bust up the grid. I tried using renderChunk and ran the snippet through there, but that seems to overwrite all of the notes authors.

    So, i'm hoping this is fairly simple and I just have a blind spot. any thoughts? pasting both of my configs below.

    Thanks!
    Anthony
      • 4172
      • 5,888 Posts
      when you use the renderChunk - renderer, you have to use another,unused fieldname for that column.
      Otherwise the field gets overwritten with the rendered value.
        -------------------------------

        you can buy me a beer, if you like MIGX

        http://webcmsolutions.de/migx.html

        Thanks!
        • 37143
        • 74 Posts
        Hi Bruno, thanks for the reply. I can't say I followed 100%. Are you saying to take my author field TV, set it's input TV to "newTV",

        and then in the column view, do I set the field value to "author" or "newTV"?

        and run a renderChunk with [[!GetImageList? &tpl=`author-tpl` &tvname=`newTV`]]?

        Confused....thanks for any help again, I really appreciate it.

          • 4172
          • 5,888 Posts
          I think, I'm confused, too.

          Not sure, to understand, what you need.
          Is it the hidden-field with the createdby - value, which defaults to the current manager-user, what you are asking for, or is it the value, shown in a column of the grid, where you have trouble with?
            -------------------------------

            you can buy me a beer, if you like MIGX

            http://webcmsolutions.de/migx.html

            Thanks!
            • 37143
            • 74 Posts
            Well, I think both. LOL.

            I'll try and re-state, see if it helps. So I have a nested MigX TV called note, which feeds into a Notes TV. I want to also show the author of each note, so i created a second field named author. I want this field to auto populate with the username of the modx manager user. I obviously want to hide it from the input view, but show it in the column grid, so they can see who wrote the note.

            Leads is the Migx Config that appears in the CMP page. Notes config is the nested setup.

            Here are some screenshots....I appreciate you reviewing and if I'm not making any sense, please feel free to let me know and tell me to bug off smiley

              • 4172
              • 5,888 Posts
              this seems to work:

              {
              "header":"Author",
              "dataIndex":"author"
              },{
              "header":"Author name",
              "dataIndex":"renderAuthor",
              "renderer":"this.renderChunk",
              "renderchunktpl":"[[+author:userinfo=`username`]]"
              }
              



                      "field":"author",
                      "caption":"",
                      "description":"",
                      "description_is_code":"0",
                      "inputTV":"",
                      "inputTVtype":"hidden",
                      "validation":"",
                      "configs":"",
                      "restrictive_condition":"",
                      "display":"",
                      "sourceFrom":"config",
                      "sources":"",
                      "inputOptionValues":"",
                      "default":"@CHUNK getuser",


              chunk getuser:

              [[+modx.user.id]]
              
                -------------------------------

                you can buy me a beer, if you like MIGX

                http://webcmsolutions.de/migx.html

                Thanks!
                • 37143
                • 74 Posts
                Thanks! Now if I can just replicate what you did !!!

                I basically have it working where it seems to work fine when I create the note. If you look at screenshots, the note "added by jason" shows jgrant as the username.

                But when I go to edit that note after it is saved, then it switches it to another user in the author field "acaffiero", and a subsequent save replaces "jgrant" with "acaffiero". This all happens while logged into manager as user "jgrant".




                  • 4172
                  • 5,888 Posts
                  hmm...
                  when I'm logged in as john, I get john as createor.
                  when I edit the same entry, the creator doesn't change.

                  let me see all your formtabs and columns-code, please (no screenshot)
                    -------------------------------

                    you can buy me a beer, if you like MIGX

                    http://webcmsolutions.de/migx.html

                    Thanks!
                    • 37143
                    • 74 Posts
                    sure, let me know if this is what you need. Thank you for looking!
                      • 4172
                      • 5,888 Posts
                      yeah, needs to be another,unused fieldname for the renderChunk-column for example:

                          {
                            "MIGX_id":2,
                            "header":"Author",
                            "dataIndex":"render_the_authorname",
                            "width":50,
                            "sortable":"false",
                            "show_in_grid":1,
                            "customrenderer":"",
                            "renderer":"this.renderChunk",
                            "clickaction":"",
                            "selectorconfig":"",
                            "renderchunktpl":"[[+author:userinfo=`username`]]",
                            "renderoptions":"",
                            "editor":""
                          }
                        -------------------------------

                        you can buy me a beer, if you like MIGX

                        http://webcmsolutions.de/migx.html

                        Thanks!