amphtml: Unable to setState on chained submit-success

unable to set states on submit-success event of form getting Trust level error as low can we have it as High?

this happens when we are trying to submit another form on the submit-success event of a form

example:

<form action="apicall1" on="submit-success: AMP.setState({dummyName:"Asda"})" id="f1">
<!-- fields -->
</form>

<form action="apicall2" on="submit-success: f1.submit" id="f2">
<!-- fields -->
</form>

on the submit-success of form f1 it is not able to set the state because it shows it has low trust level to set the state

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Comments: 16

Most upvoted comments

I will try to explain in layman terms Our page consists two form section

  1. Form 1 - User info section like Name, Email
  2. Form 2 - Mobile field with OTP section After succesful OTP verification in Form 2, we call both Amp.setState and Form 1 submit action in chain from Form 2 success-submit event.

This Form 1 submit action failed and we get following error in console - “submit-success” event with “low” trust is not allowed to invoke “amp.setState”.

above we try to frame a pseudo code for this instance also. I hope we were able to explain from our side this scenario. In case you need more info then let us know.

we have a main form that collects user name and mobile no. we then on submission of mobile no. verify it by calling an otp verificationApi (by submitting a form). If the verificationApi returns success, we call the form.submit of the main form in the submit-success event.

Why not do OTP verification on the backend at the same time as the username/mobile number submission? This would avoid two roundtrips on client which is definitely slower.