2

I'm in the process of making an administration app for Joomla RSform! pro. The app is hosted as an article so it is on the same domain as Joomla itself.
I need to move or copy a submission from one RSform to another. The fields on the two forms, are not necessarily the same, but most of them are, however I can easily find witch fields that are on the new form.

What I have done untill now is that I get all the fields, and then make a javascript object looking something like this:

formElements = {
    form:{
        username:'username',
        something:'something
    },
    hidden:{ somethinghidden:'somethinghidden'}
}

my question is now: How do I send this to the rsform.

I use the jQuery.ajax, but it doesn't work.

jQuery.ajax({
    method: "POST",
    url: '/index.php?option=com_rsform&formId=' + fromID,
    data: formElements,
    timeout: 10000,
    dataType: 'html'
}).fail(function (msg) {
}).done(function (msg) {
});

the url is the same as the one that is in the tag on the submission form. So I guess this is correct as well.

I have also made a fake nodejs server where I try and submit to using the normal forms that RSforms provide, and the post object I got from there is identical to the object i create.

What am I doing wrong? Do I need to set some headers or something? or what am I missing...?

Hope someone can help, and my question make sense...

/thanks..

  • 1
    Are you trying to take existing data stored from one form and then reassign it to another form? Or are you trying to make a completely separate form post to RSForms? Unless I am misunderstanding what you are trying to do, it seems like you would be better off doing an UPDATE SQL statement for those rows in the submissions table or if new data, just inserting the new rows into the RSForm submission table. – YellowWebMonkey Jan 27 '16 at 3:08
  • Completely separate form post. I cannot just move (Update) since the two forms doesn't have the same fields. however the data in the new form can be calculated from the date in the old form. But updating could be a solution, however i'm afraid of breaking the database. lots of data is in there. – pjensen68321 Jan 27 '16 at 9:11
1

In Joomla, forms have a session token to prevent CSRF.

Cross-Site Request Forgery (CSRF) is a type of attack that occurs when a malicious Web site, email, blog, instant message, or program causes a user's Web browser to perform an unwanted action on a trusted site for which the user is currently authenticated.

If you submit information from Ajax, you must follow the rules to include the token in form POST, GET or Url. Otherwise, it will be rejected.

Ref: How to add CSRF anti-spoofing to forms

  • Nice thank you. :) i did however just edit the sql but this is definitely what i was looking for. – pjensen68321 Feb 19 '16 at 19:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.