Results 1 to 4 of 4

Thread: How to insert csrf token into extjs form?

  1. #1
    Sencha User
    Join Date
    May 2009
    Posts
    12

    Default How to insert csrf token into extjs form?

    I've upgraded to Django 1.1.2 which requires some changes for forms.

    Code:
    <form action="" method="post">{% csrf_token %}
    Is there an easy way to put this Django template tag, {% csrf_token %}, into my ExtJs forms?

  2. #2
    Ext JS Premium Member
    Join Date
    Dec 2010
    Posts
    6

    Talking

    You could try surrounding the csrf code with a hidden div tag e.g.

    <div id="hidden-csrf" class="x-hidden">
    {% csrf_token %}
    </div>

    Then use the hidden div tag as the source for one of your form fields in your ExtJs FormPanel e.g.

    var myForm = new Ext.FormPanel(
    {

    ... form init attributes

    items: [
    {
    hidden: true,
    contentEl: "hidden-csrf"
    },
    ... other form fields
    ]

    }
    );

    I've used this technique within Rails to make Devise forms much more ExtJs like.

    Good luck.

  3. #3
    Sencha User
    Join Date
    May 2009
    Posts
    12

    Default

    That was easy, thanks

  4. #4
    Sencha User
    Join Date
    Nov 2009
    Posts
    3

    Default

    Alternative solution which does not involve changing templates: http://stackoverflow.com/questions/3...485616#5485616

Similar Threads

  1. How to insert Images in extjs
    By ranjeet in forum Ext 2.x: Help & Discussion
    Replies: 5
    Last Post: 16 May 2013, 11:53 PM
  2. Replies: 10
    Last Post: 2 Jan 2011, 4:52 PM
  3. HOW TO INSERT XML POST IN EXTJS FORM?
    By snehal in forum Ext 3.x: Help & Discussion
    Replies: 0
    Last Post: 16 Aug 2009, 9:33 AM
  4. Adding a Token
    By boriscy in forum Ext 2.x: Help & Discussion
    Replies: 2
    Last Post: 26 Mar 2008, 11:03 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •