Skip to content
This repository has been archived by the owner on Jul 25, 2023. It is now read-only.

Latest commit

 

History

History
53 lines (35 loc) · 1.9 KB

README_Confirm.md

File metadata and controls

53 lines (35 loc) · 1.9 KB

Confirm Modal :

AlertifyBundle eases the confirm dialog you may use when protecting link or form.

Installation:

Please note that FOSJsRoutingBundle is required so you need to setup it properly before following next steps.

Add this to your routing.yml file:

AvAlertifyBundle:
    resource: "@AvAlertifyBundle/Controller/"
    type:     annotation
    prefix:   /

Add this to your template:

<script src="{{ asset('bundles/avalertify/js/confirm.js') }}"></script>

Use

Add the following attributes to your link|form tag :

  • data-toggle="confirm"
  • data-confirm-class="myModal"
  • data-title="Are you sure ?"
  • data-body="This is forever !"
  • data-cancel-button-class="btn-cancel"
  • data-confirm-button-class="btn-primary"

You can also add a callback like this:

  • data-confirm-callback="someFunctionToRunIfTheConfirmButtonIsClicked();"

In this cas, after confirm, the link won't be directly followed (or the form won't be submit). Instead of that, the js we'll be ran.

Example :

Form :

<form action="/your_url" data-toggle="confirm" data-confirm-class="myModal" data-title="Sur ?" data-body="Butterfly will die. Do you confirm ?" data-cancel-button-class="cancel" data-confirm-button-class="danger" method="post" {{ form_enctype(delete_form) }}>
	{{ form_errors(delete_form) }}
	{{ form_widget(delete_form) }}
    <input type="submit" class="btn btn-danger span4" style="width:100%" value="Kill Butterfly"/>
</form>

link :

<a href="/your_url" class="btn btn-mini btn-danger" data-toggle="confirm" data-title="Are you sure ?" data-body="Kittens will suffer ! Do you confirm ?" data-cancel-button-class="cancel" data-confirm-button-class="danger">Burn some cats</a>