We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
  • discuss.answer
    • 4172
    • 5,888 Posts
    this should work:

    function tcsave(){
    var e = $(this).parent().parent();
    var t = e.children("td:nth-child(1)");
    var n = e.children("td:nth-child(2)");
    var r = e.children("td:nth-child(3)");
    var i = e.children("td:nth-child(4)");
                 
    var u = n.children("input[type=text]").val();
                 
    var f = "object_id=" + t.html() + "&sr_description=" + u;
    $.post("portal/edit-service-request", f, function(e) {
         if (!$(e).find("#tcerrors").length) var t = e;
         else {alert("Some Error :(");
         return false
         }
    })
    }
    


    [[!FormIt?
        &hooks=`spam,Formit2db`
        &preHooks=`db2formit`
        &packagename=`service_requests`
        &classname=`service_requests`
        &tablename=`service_requests`
        &where=`{"id":"[[!getObjectId]]"}`
        &validate=`
            nospam:blank,
            sr_description:required`
        &successMessage=`It works`
    ]]
     
    <form class="form" action="[[~[[*id]]]]" method="post">
        <div id="tcerrors">[[!+fi.validation_error_message]]</div>
        [[!fi.successMessage]]
        <input name="nospam" type="hidden" />
        <input name="object_id" type="text" value="[[!getObjectId]]"/>
        <input name="sr_description" type="text" value="[[+fi.sr_description]]"/>
        <input type="submit" value="Save"/>
    </form>
      -------------------------------

      you can buy me a beer, if you like MIGX

      http://webcmsolutions.de/migx.html

      Thanks!
      • 44437
      • 74 Posts
      Hey Bruno,

      I tried your code and I got the same error. I even created a resource with a BaseTemplate and used the following code and it is not updating the field. I also tried it on another modx site with no success. It was working before on the other site but now it is not working. Could it be a bug?

      [[!FormIt? 
          &hooks=`spam,formit2db` 
          &preHooks=`db2formit`
          &prefix=`modx_`
          &packagename=`mytoyota_vehicles`
          &classname=`mytoyota_vehicles`
          &tablename=`mytoyota_vehicles`
          &paramname=`object_id`
          &where=`{"id":"[[!getObjectId]]"}`
          &validate=`
              nospam:blank,
              model:required`
      ]]
      <form class="form" action="[[~[[*id]]]]" method="post">
          <div>[[!+fi.validation_error_message]]</div>
          [[!fi.successMessage]]
          <input name="nospam" type="hidden" value=""/>
          <input name="object_id" type="text" value="[[!getObjectId]]"/>
          <input name="model" type="text" value="[[+fi.model]]"/>
          <input type="submit" value="Save"/>
      </form>


      Error message
       [2015-02-04 18:10:42] (ERROR @ /index.php) Error 42S22 executing statement: 
      Array
      (
          [0] => 42S22
          [1] => 1054
          [2] => Unknown column 'mytoyota_vehicles.object_id' in 'where clause'
      )
      
      [2015-02-04 18:10:42] (ERROR @ /index.php) Error 42S22 executing statement: 
      Array
      (
          [0] => 42S22
          [1] => 1054
          [2] => Unknown column 'mytoyota_vehicles.object_id' in 'where clause'
      )
      
      
      [ed. note: random_noob last edited this post 11 years, 7 months ago.]
        • 4172
        • 5,888 Posts
        you did it wrong.
        This is not my code.
        You did change my code.
          -------------------------------

          you can buy me a beer, if you like MIGX

          http://webcmsolutions.de/migx.html

          Thanks!
          • 44437
          • 74 Posts
          Ok, I see what is different. Thanks