function flexiform_modal_wrapper in Flexiform 7
Form callback wrapper: flexiform modals.
Parameters
$flexiform: The flexiform being wrapped.
$base_entity: The base entity for this form.
string $display: The active modal display.
1 string reference to 'flexiform_modal_wrapper'
- FlexiformDisplayCreateModal::build in includes/
display/ add_modal.display.inc - Build the form ready for rendering.
File
- includes/
flexiform.flexiform.inc, line 66 - flexiform.flexiform.inc Helper function for embedding the fields into the flexiform in an arbitrary order
Code
function flexiform_modal_wrapper($flexiform, $base_entity, $display) {
ctools_include('ajax');
ctools_include('modal');
// Prepare form id and form args.
$form_id = "flexiform__{$flexiform->form}";
$args = array(
$flexiform,
$base_entity,
);
// Setup form state.
$form_state = array(
'ajax' => TRUE,
'build_info' => array(
'args' => $args,
),
);
$commands = ctools_modal_form_wrapper($form_id, $form_state);
if (!empty($form_state['executed']) && empty($form_state['rebuild'])) {
$configuration = $flexiform
->getDisplay($display)->configuration;
// The form has been executed, so let's redirect to the destination page.
$commands = array();
if (!empty($_GET['destination'])) {
$commands[] = ctools_ajax_command_redirect($_GET['destination']);
}
elseif (!empty($form_state['redirect'])) {
$options = array();
if (is_array($form_state['redirect'])) {
list($url, $options) = $form_state['redirect'];
}
else {
$url = $form_state['redirect'];
}
$commands[] = ctools_ajax_command_redirect($url, 0, $options);
}
elseif ($configuration['ajax_behavior'] == 'modal_dismiss') {
$commands[] = ctools_modal_command_dismiss();
}
else {
$commands[] = ctools_ajax_command_reload();
}
}
drupal_alter('flexiform_modal_submit_commands', $commands, $flexiform, $form_state);
ajax_deliver(array(
'#type' => 'ajax',
'#commands' => $commands,
));
drupal_exit();
}