We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 3749
    • 24,544 Posts
    Bob, could the snippet calls be changed to [[!ShowQuotes]] etc. Would have saved me an hour. Obvious in hindsight.

    Done! Thanks for the feedback and sorry about the confusion.
      Did I help you? Buy me a beer
      Get my Book: MODX:The Official Guide
      MODX info for everyone: http://bobsguides.com/modx.html
      My MODX Extras
      Bob's Guides is now hosted at A2 MODX Hosting
      • 34118
      • 45 Posts
      Thanks Bob for the fix.

      All,

      I've made a lot of progress. With Formit, FormitFastPack and Formit2Db I've built a large form and am able to update new rows in the database. Without breaking anything. Great.


      Now trying to add an Edit facility. Used Bob's Guide again creating a snippet to get a specific row and if not POSTed simply call the previously used Formit/Formitfastpack chunk to display the Form but with values from the database.

      Not going well. Form appears but values are blank.

      Was using a line like this
      $output = $modx->getChunk('meetingRoomFormIt',$booking->toArray() ); // attempt to populate form but perhaps db2formit will do this?


      Where $booking contains the database row (which I know is populated). But as my comment suggests I now think that db2formit should handle this. Assuming it is given a where clause to tell it to go get a specific row and then $hook->setValues($formFields); will populate the Form.
      But nothing is happening.

      1) hints on debugging this kind of thing would be appreciated but I've done this -
      return ('Forename: ' . $booking->get('Forename')); and the correct name is being returned so the database read is working. Good.

      2) is my where clause correct? see code below ( can't find any examples even close to what I'm trying to do)

      3) Will db2formit cope with FormItFastPack. I'm worrying about db2formit expecting to replace a placeholder like value=`[[!+fi.someFieldName]]` or perhaps from the FormItFastPack chunk fieldtypestpl <input ... value="[[+current_value:default=`[[+default]]`]]" .... />

      But my hunch is that hook->setValues will do just that: force the input values to the correct value regardless of placeholders.

      Code snippet. Not convinced by the where clause.

      [[!FormIt? &hooks=`spam,formit2db,email` &submitVar=`submitForm`
      &preHooks=`db2formit` &where=`{'id':'336'}` &prefix=`risk_` &packagename=`meetingrooms` &tablename=`meetingroombooking` &classname=`Meetingroombooking` ... ]]
      
      [[!field? &name=`Title` &type=`text` &outer_tpl=`myFieldWrapTpl` ]]
      [[!field? &name=`Forename` &type=`text` &class=`required` &outer_tpl=`myFieldWrapTpl` ]]
      


      Summary. Trying to get db2formit and formitfastpack to work via a $modx->getChunk call as per Bob's Guide.

      Revo.2.2.10 and latest applicable packages.

      Ta Muchly

      Stuart [ed. note: parthian last edited this post 12 years, 9 months ago.]
        • 3749
        • 24,544 Posts
        I've never used FormIt2DB or FormItFastPack, so I'm not the person to answer this.


          Did I help you? Buy me a beer
          Get my Book: MODX:The Official Guide
          MODX info for everyone: http://bobsguides.com/modx.html
          My MODX Extras
          Bob's Guides is now hosted at A2 MODX Hosting
          • 4172
          • 5,888 Posts
          did you try
          &where=`{"id":"336"}`
            -------------------------------

            you can buy me a beer, if you like MIGX

            http://webcmsolutions.de/migx.html

            Thanks!
            • 34118
            • 45 Posts
            Brilliant Bruno

            What a difference a double quote makes.

            Form now displays all my stuff. Wasn't far away. Had forgotten JSON always needs double quotes - so not just a MODx thing.

            Now just need to make the "336" dynamic and I'll be well on the way.

            Conceptual Point
            I had hoped to have one Formit/FastPack Chunk for both Creation and Editing. But the latter needs a Where clause. So unless I can think of a way of only adding the &where=`{'id':'ARowIDfromQueryParam'}` line if a Query Param exists then I may have to have a creation Chunk and an Editing Chunk.
            I'll look into using an Output modifier.

            I'll report back probably Monday when I hope to have a fully working system.

            Cheers.