Skip to content

Instantly share code, notes, and snippets.

@init90
Created December 28, 2016 08:29
Show Gist options
  • Select an option

  • Save init90/8d1cae8b866623ec295a0a44f5426f7e to your computer and use it in GitHub Desktop.

Select an option

Save init90/8d1cae8b866623ec295a0a44f5426f7e to your computer and use it in GitHub Desktop.
drupal 7, display add entity form in ctools popup.
/**
* Create default entity in ctools popup.
*/
function cba_events_create_default_entity_in_popup($js, $user_id) {
if (!$js) {
return drupal_goto('event/default/add');
}
ctools_include('ajax');
ctools_include('modal');
ctools_modal_add_js();
$entity = entity_create('event', array('type' => 'default'));
$form_state = array(
'ajax' => TRUE,
'title' => t('Add default event'),
'build_info' => array(
'args' => array($entity),
),
);
$form = ctools_modal_form_wrapper('eck__entity__form_add_event_default', $form_state);
if (!empty($form_state['executed'])) {
$commands = array();
$commands[] = global_ajax_command_reload();
print ajax_render($commands);
drupal_exit();
}
print ajax_render($form);
drupal_exit();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment