天天看点

rails使用html form,Rails submit html form in addition to model form

I'm fairly new to rails with very small knowledge of javascript. That's the disclaimer :)

I'm using simple form and haml in a rails app to create an instance of a model. The code is simple, and works well. It's essentially this...

= simple_form_for @account, :validate => true, :url => { :action => 'create' } do |account|

= account.input :name, :placeholder => "Company name", :label => false

= account.input :first_name, :placeholder => "First name", :label => false

= account.input :last_name, :placeholder => "Last name", :label => false

= account.submit "Create my account"

I have simplified the above.

My sales team have come to me and asked me to create a lead in salesforce every time a new account is created. Salesforce have functionality at the cheap end called web to lead, which is essentially a web form. Again, a simplified version of the form looks like this...

First Name

Last Name

Company

now, my thoughts are that I can populate this form with variables from the screen and then somehow get the rails simple_form to submit the html form when it is submitted. I have access to guys who know java and ajax if necessary, but I'm looking for the best and easiest solution.

so my two questions are

Is it possible to have a hidden form and have the simple_form submit button submit both forms

what's the best approach to this problem