Hi there,

how to make a node/delete confirm modal? I have a view with this link in it..
I add rewrite the link like that node/uid/delete/nojs

but what I have to write in a module, to make this modal?

Comments

Apfel007’s picture

anyone?

create the modal with this in a view.views-field..
$output = ctools_modal_text_button(t('DELETE'), 'node/' .$row->nid .'/delete', t('delete'));

But it's empty!

How to load the form into the modal? Need a callback .. but how to call it?

create a menu item?

ha5bro’s picture

A bit late to the party, but this is really easy using the automodal module. You'll just need to add a class to your delete button using form alter and the rest is automagical.

pfrenssen’s picture

Version: 6.x-1.8 » 7.x-1.x-dev
Category: task » support
Status: Active » Fixed

No need for the automodal module. This is built in to CTools: #1347578: Allow certain links inside the modal to be able to close the modal.

You need to add the class 'ctools-close-modal' to the links that should close the dialog. An example with a confirm_form():

/**
 * Implements hook_form_FORM_ID_alter().
 */
function MYMODULE_form_MYFORM_alter(&$form, &$form_state) {
  $form['actions']['cancel']['#attributes']['class'][] = 'ctools-close-modal';
}

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

pringlz’s picture

Issue summary: View changes

Module Modal operaitons do this. https://www.drupal.org/project/modal It is no readme, but here is example. This link was open node view in modal window.

//As Example:
<a href="/modal/node/NID/nojs" class="ctools-use-modal">View</a>.

Or this my code for delete node (for Views PHP)
<a href="<?php global $base_url; echo $base_url; ?>/modal/node/<?php echo $row->nid; ?>/delete/nojs" class="ctools-use-modal">Delete</a>