Add submission response to event details in tinyforms.js
This makes the submitted data more easily accessible
This commit is contained in:
parent
6e3e3ff8f6
commit
dfa621d0bc
@ -14,7 +14,7 @@ class SubmissionsController < ApplicationController
|
|||||||
respond_to do |format|
|
respond_to do |format|
|
||||||
if @submission.save
|
if @submission.save
|
||||||
format.html { redirect_to(@form.thank_you_url) if @form.thank_you_url.present? }
|
format.html { redirect_to(@form.thank_you_url) if @form.thank_you_url.present? }
|
||||||
format.json { render(json: { success: true, data: @submission.data }) }
|
format.json { render(json: { success: true, submission: @submission.data }) }
|
||||||
else
|
else
|
||||||
format.html { redirect_to(@form.thank_you_url) if @form.thank_you_url.present? }
|
format.html { redirect_to(@form.thank_you_url) if @form.thank_you_url.present? }
|
||||||
format.json { render(json: { error: @submission.errors }, status: 422) }
|
format.json { render(json: { error: @submission.errors }, status: 422) }
|
||||||
|
@ -38,10 +38,10 @@ window.tinyforms = {
|
|||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
return tinyforms.submitForm(this)
|
return tinyforms.submitForm(this)
|
||||||
.then((response) => {
|
.then((response) => {
|
||||||
this.dispatchEvent(new CustomEvent('tinyforms:submitted', {detail: { response: response }}));
|
this.dispatchEvent(new CustomEvent('tinyforms:submitted', {detail: { submission: response.submission, response: response }}));
|
||||||
})
|
})
|
||||||
.catch((response) => {
|
.catch((response) => {
|
||||||
this.dispatchEvent(new CustomEvent('tinyforms:error', {detail: { response: response }}));
|
this.dispatchEvent(new CustomEvent('tinyforms:error', {detail: { submission: response.submission, response: response }}));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
Loading…
x
Reference in New Issue
Block a user