You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Tomek Gryszkiewicz edited this page Feb 15, 2018
·
1 revision
If you re-render the whole form which uses CSRF token (like with form_for helper), you may experience "invalid CSRF token" on submit this form. The solution is to store the token before rendering the form, and put it back again:
# safe the existing token{:ok,%{"value"=>token}}=query_onesocket,"form > input[name='_csrf_token']",:value# re-render the formpokesocket,"#form_holder",innerHTML: Phoenix.View.render(MyView,"form.html",assign: "value")# set the token backset_attrsocket,"form > input[name='_csrf_token']",value: token