0

I baked a cakephp project where i want to use nifty-modalbox for delete confirmation in place of normal alert. Anyone have idea how to do that.

Here is the scenario: Bootstrap 3 jquery.niftymodals.js

Here is the desired html code.

<a class="btn btn-primary btn-mono2 btn-flat md-trigger" data-modal="dark-primary">Delete</a>
<!-- Nifty Modal -->
                <div class="md-modal md-dark md-effect-3" id="dark-primary">
                    <div class="md-content">
                      <div class="modal-header">
                        <h3>Custom Header Color</h3>
                        <button type="button" class="close md-close" data-dismiss="modal" aria-hidden="true">&times;</button>
                      </div>
                      <div class="modal-body">
                        <div class="text-center">
                          <h4><strong>Awesome!</strong></h4>
                          <h5>Can you say supercalifragilisticoexpialidoso?</h5>
                        </div>
                      </div>
                      <div class="modal-footer">
                        <button type="button" class="btn btn-primary btn-mono2 btn-flat md-close" data-dismiss="modal">Cancel</button>
                        <button type="button" class="btn btn-primary btn-mono2 btn-flat md-close" data-dismiss="modal">Proceed</button>
                      </div>
                    </div>
                </div>

Cakephp code:

<?php   echo $this->Form->postLink(__('Delete'), array('action' => 'delete', $post['Post']['id']), null, __('Are you sure you want to delete # %s?', $post['Post']['id'])); ?>

Can anyone suggest ?

1 Answer 1

1

If you want to use cakePHP for this you can create your own helper, and let it extend FormHelper. Then you override the postLink method and tailor it after your needs. The file you want to be looking for is Cake/View/Helper/FormHelper.php. This is the current cakePHP implementation for the confirmation dialog (starts at line 1786):

if ($confirmMessage) {
            $confirmMessage = str_replace(array("'", '"'), array("\'", '\"'), $confirmMessage);
            $options['onclick'] = "if (confirm('{$confirmMessage}')) { {$onClick} }";
}

Good luck!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.