We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 10355
    • 44 Posts
    ok, we do it in small steps, because I haven’t much time at the moment, sorry.
    thanks a lot for that helps me
    I’ll wait for your help

    ОК. Name the table "modx_addgoods"
    A list of fields:
    id
    name
    article
    color
    parent

      • 4172
      • 5,888 Posts
      I would rename that table, so you have an unique prefix, for example:

      modx_custom_addgoods
        -------------------------------

        you can buy me a beer, if you like MIGX

        http://webcmsolutions.de/migx.html

        Thanks!
        • 10355
        • 44 Posts
        OK.
        add prefix
          • 4172
          • 5,888 Posts
          now you can call formit with:

          [[!FormIt? 
          &hooks=`spam,formit2db,email` 
          &preHooks=`db2formit`
          &prefix=`modx_custom_`
          &packageName=`goods`           <- here the Name for your new package 
          &tablename=`addgoods`
          &emailTpl=`myEmailChunk` 
          &emailTo=`[email protected]`]]


          make sure your folder /core/components is writeable.
          The prehook db2formit should now create the new package ’goods’ with schema and xpdo-classes automatically under /core/components/goods/
          Does it?
          Now db2formit and formit2db can read and write from your table per xpdo.

          more questions?
            -------------------------------

            you can buy me a beer, if you like MIGX

            http://webcmsolutions.de/migx.html

            Thanks!
            • 10355
            • 44 Posts
            ОК db2formit create the new package ’goods’ with schema and xpdo-classes automatically under /core/components/goods/
            but how to add data to the table "modx_custom_addgoods"?
            I call formit
            [[!FormIt? 
            &hooks=`spam,formit2db,email` 
            &preHooks=`db2formit`
            &prefix=`modx_custom_`
            &packageName=`goods` 
            &tablename=`addgoods`
            &emailTpl=`myEmailChunk` 
            &emailTo=`[email protected]`]]
            
            <h2>Resource Form</h2>
            <p>[[+fi.error.error_message]]</p>
            <form class="form" action="[[~[[*id]]]]" method="post">
                <input name="nospam:blank" type="hidden" />
                <input name="resource_id" type="hidden" value="[[+fi.id]]" />
            
                <label for="name">Name:<span class="error">[[+fi.error.name]]</span></label>
                <input id="name" name="name:required" type="text" value="[[+fi.name]]" />    
                <br/>
                <label for="address">Address:<span class="error">[[+fi.error.address]]</span></label>
                <input id="address" name="address:required" type="text" value="[[+fi.address]]" />
            
                <br class="clear" />
                <div class="form-buttons">
                    <input type="submit" value="Save" />
                </div>
            </form>
            I fill out the form click on Save but in the table "modx_custom_addgoods" no data
              • 4172
              • 5,888 Posts
              hmm... this should work.
              You have the latest version of formit?
                -------------------------------

                you can buy me a beer, if you like MIGX

                http://webcmsolutions.de/migx.html

                Thanks!
                • 10355
                • 44 Posts
                FormIt 1.5.0-pl
                MODx Revolution 2.0.4-pl2

                Perhaps there are errors in the form?
                  • 4172
                  • 5,888 Posts
                  Do you see errors in your error-log?
                  what do you get when you alter this lines in formit2db:

                  //$errorMsg = '<pre>'.print_r($scriptProperties['fields'],true).'</pre>';  
                  //$hook->addError('error_message',$errorMsg);  


                  to

                  $errorMsg = '<pre>'.print_r($scriptProperties['fields'],true).'</pre>';  
                  $hook->addError('error_message',$errorMsg);  


                  or to

                  $allFormFields = $hook->getValues(); 
                  $errorMsg = '<pre>'.print_r($allFormFields,true).'</pre>';  
                  $hook->addError('error_message',$errorMsg);  
                    -------------------------------

                    you can buy me a beer, if you like MIGX

                    http://webcmsolutions.de/migx.html

                    Thanks!
                    • 10355
                    • 44 Posts
                    Do not know how, but after reinstalling fofmit and re-created formit2db it worked.
                    Thank you very much for your help and for this wonderful snippet!
                      • 10355
                      • 44 Posts
                      hello again
                      I have another problem
                      when editing the resources I add to the URL & resId = 10, appear in the form of resource data 10 but when you save does not update resource 10, and creates the following resource 11 with data from the form. how to fix?

                      and how best to do a background check on the right to edit the resource only by the author?