{% extends 'dashboard/new_base.html' %}
{% block title %}
Change Password
{% endblock %}
{% block content %}
<div class="row no_row_margin heading_count">
  <div class="heading col-md-6" id='page_title'>
    Change Password
  </div>
</div>
<!-- end class of row -->
<div class="row no_row_margin">
  <div class="container-fluid">
    <form action="" id="post-form" enctype="multipart/form-data" method="post" role="form">
      {% csrf_token %}
      <div class="row form_row no_row_margin">
        <div class="col-md-12">
          <div class="col-md-6">
            {% for field in form %}
                <div class="form-group col-md-12">
                  <label>{{ field.label }} :</label>
                  <div class="controls">
                    {{ field }}
                    {% if field.help_text %}
                    <p class="help-inline"><small>{{ field.help_text }}</small></p>
                    {% endif %}
                  </div>
                </div>
            {% endfor %}
          </div>
        </div>
        <br clear="all">
        <div class=" col-md-12 buttons_row text-left">
          <div class="form-group">
            <button type="submit" class="btn btn-default green_btn"> <i class="fa fa-floppy-o" aria-hidden="true"></i> Submit</button>
            <button type="reset" class="btn btn-default blue_btn"> <i class="fa fa-refresh" aria-hidden="true"></i> Reset</button>
          </div>
        </div>
      </div>
    </form>
  </div>
</div>
<!-- end div row of form -->
{% endblock %}
{% block js_script %}
<script type="text/javascript">
  $('#post-form').submit(function(event){
    event.preventDefault()
    $.post("", $(this).serialize(), function(response){
      $('.error').remove();
      if(response.error){
        $.each(response.errors, function(name, error){
          $("[name=" + name + "]").after("<span class='error'>" + error + "</span>")
        });
      }
      else{
        window.location = response.success_url
      }
    }, 'json');
  });
</script>
{% endblock %}