function views_megarow_display_form_wrapper in Views Megarow 7
This callback is just a testing wrapper to display an ajaxified form or its fallback if it's not called through AJAX.
File
- ./
views_megarow.module, line 240
Code
function views_megarow_display_form_wrapper($js, $form_id, $entity, $entity_type) {
if ($js) {
list($entity_id) = entity_extract_ids($entity_type, $entity);
$form_state = array(
'ajax' => TRUE,
'build_info' => array(
'args' => array(
$entity_type,
$entity,
),
),
);
$commands = views_megarow_form_wrapper($form_id, $form_state, $entity_id);
if (!empty($form_state['executed'])) {
// We'll just overwrite the form output if it was successful.
$messages = theme('status_messages');
$message = 'Submission completed. You can now close this row. ' . $messages;
$commands = array();
$commands[] = views_megarow_command_display('Submit OK', $message, $entity_id);
// Invoke a custom event that refresh the table row of this item.
$commands[] = ajax_command_invoke('.item-' . $entity_id, 'trigger', array(
'refreshRow',
));
}
print ajax_render($commands);
exit;
}
else {
return drupal_get_form($form_id, $entity
->entityType(), $entity, $form_mode);
}
}