We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 37143
    • 74 Posts
    Does anyone have an example of the db2FormIt successfully working (ie populating fields in the form with data)? I have the same question stowelly had at the end of page 8 of this thread (copied below in quote)

    I'm not sure how to setup the FormIt call parameters &paramname and &fieldname and how to use them, and how the &where factors in....can anyone quickly post an example?

    Quote from: stowelly at Sep 18, 2013, 06:52 PM
    if you want to edit table-row add &resId=yourRowID to your URL <- replace yourRowID with id of tablerow

    im having trouble with working out how this is supposed to work? is row id the primary key in my table? for one table I have a dual key, how would that work?

    also I cant see any reference to "resId" in the code from package manager, so im guessing from the docs im supposed to use the "where" clause? I cant seem to get this correct either, here is my formit call

    [[!FormIt? 
    &hooks=`spam,formit2db,email` 
    &preHooks=`db2formit`
    &prefix=`user_`
    &packagename=`test`
    &tablename=`test`
    &classname=`test`
    &where='{"user_id":12}'
    ]]


    but it doesnt do what i am hoping...... I was hoping that if a value was specified then it would grab that row from my db and fill the fields (provided i use the fi.fieldname type bits).... will paste my whole resource in, incase anyone can see what it is im doing wrong, but im really stumped with this!

    [[!FormIt? 
    &hooks=`spam,formit2db,email` 
    &preHooks=`db2formit`
    &prefix=`user_`
    &packagename=`test`
    &tablename=`test`
    &classname=`test`
    &where='{"user_id":12}'
    ]]
     
    <h2>Resource Form</h2>
    [[+fi.id]]
    <p>[[+fi.error.error_message]]</p>
    <form class="form" action="[[~[[*id]]]]" method="post">
    <input name="resource_id" type="hidden" value="[[+fi.id]]">
        <input name="nospam" type="hidden">
        <label for="user_id">
            user_id:
            <span class="error">[[+fi.error.user_id]]</span>
        </label>
        <input id="user_id" name="user_id" type="number" value="[[+fi.user_id]]">    
         
     
        <label for="address">
            address:
            <span class="error">[[+fi.error.address]]</span>
        </label>
        <input id="address" name="address" type="text" value="[[+fi.address]]">
    <br class="clear">
    <div class="form-buttons">
            <input type="submit" value="Save">
        </div>
    </form>
      • 20413
      • 2,877 Posts
      BearsFan try this:

      [[!FormIt? 
      &hooks=`spam,formit2db,email` 
      &preHooks=`db2formit`
      &prefix=`user_`
      &packagename=`test`
      &tablename=`test`
      &classname=`test`
      &where=`{"user_id":"12"}`
      &fieldname=`user_id`
      ]]
      

        @hawproductions | http://mrhaw.com/

        Infograph: MODX Advanced Install in 7 steps:
        http://forums.modx.com/thread/96954/infograph-modx-advanced-install-in-7-steps

        Recap: Portland, OR (PDX) MODX CMS Meetup, Oct 6, 2015. US Bancorp Tower
        http://mrhaw.com/modx_portland_oregon_pdx_modx_cms_meetup_oct_2015_us_bancorp_tower