We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 4172
    • 5,888 Posts
    you need a field which holds the id:
    <input name="resource_id" type="hidden" value="[[+fi.id]]" />


    for permission you can check in formit2db or formit2resource if the user==author.
    if not return with a formit error-message.

    btw. : are you now creating modx-resources or datas in custom-table?
      -------------------------------

      you can buy me a beer, if you like MIGX

      http://webcmsolutions.de/migx.html

      Thanks!
      • 10355
      • 44 Posts
      yes you correctly write for modx-resources you need to add
      <input name="resource_id" type="hidden" value="[[+fi.id]]" />
      but I edit the custom-table.
        • 4172
        • 5,888 Posts
        this is ok, also for custom-table.
        In formit2db it uses this field to find your dataobject.
        See this line in formit2db:

        $dataobject=$modx->getObject($classname,array('id'=>$hook->getValue('resource_id')));
          -------------------------------

          you can buy me a beer, if you like MIGX

          http://webcmsolutions.de/migx.html

          Thanks!
          • 31621
          • 23 Posts
          Hi,

          I tried the above code, however, I get the message : "Failed to create object of type: Members". "Members" is my table name.

          I’m a noob, hence don’t know what ’m I missing here.

          Thanks,
          Vishal
            • 4172
            • 5,888 Posts
            which code exactly did you try?
              -------------------------------

              you can buy me a beer, if you like MIGX

              http://webcmsolutions.de/migx.html

              Thanks!
              • 19349
              • 9 Posts
              Hello,
              i´m new hier and i have the same problem like vishalashah.
              When i try to save the form it failed and i get the message ’Failed to create object of type:...’.
              Have somebody a solution?
                • 31621
                • 23 Posts
                The code in the first post. The formit snippet call and then created db2formit and formit2db snippets. The model folders under the component appear to be created as expected.
                  • 4172
                  • 5,888 Posts
                  your snippet-call is exactly the same as mine in the first post? And your tablename is ’members’ without prefix?

                  this cannot work.
                    -------------------------------

                    you can buy me a beer, if you like MIGX

                    http://webcmsolutions.de/migx.html

                    Thanks!
                    • 31621
                    • 23 Posts
                    Can you please suggest, what would work?

                    My snippet-call is as below:
                    [[!FormIt? 
                    &hooks=`spam,formit2db,email` 
                    &preHooks=`db2formit`
                    &prefix=`dcvsborg_`
                    &packageName=`vsbmdi`
                    &tablename=`members`
                    &emailTpl=`registrationEmailTpl` 
                    &emailTo=`######@gmail.com`]]
                    
                      • 4172
                      • 5,888 Posts
                      then your tablename should be: dcvsborg_members
                        -------------------------------

                        you can buy me a beer, if you like MIGX

                        http://webcmsolutions.de/migx.html

                        Thanks!