function slickgrid_undo_form in Slickgrid 7.2
Undo form.
1 string reference to 'slickgrid_undo_form'
- slickgrid_get_form in includes/
slickgrid.form.inc - Returns a form to the browser which can then be submitted - avoiding CSRF!
File
- includes/
slickgrid.form.inc, line 229
Code
function slickgrid_undo_form($form, &$form_state, $entity_type, $command) {
$keys = array_keys($command);
$id = array_pop($keys);
$entity = entity_load_single($entity_type, $id);
$info = entity_get_info('node');
return array(
'entity_type' => array(
'#type' => 'hidden',
'#value' => $entity_type,
),
'entity_id' => array(
'#type' => 'hidden',
'#value' => $id,
),
'revision_id' => array(
'#type' => 'hidden',
'#value' => $command[$id],
),
'description_text' => array(
'#markup' => '<p>' . t('Do you want to undo the latest change to @entity_type %entity_label?', array(
'@entity_type' => $entity_type,
'%entity_label' => $entity->{$info['entity keys']['label']},
)) . '</p>',
),
'actions' => array(
'cancel' => array(
'#type' => 'submit',
'#value' => t('Cancel'),
'#ajax' => array(
// We need an empty callback, as all the logic is handled in the submit
// function.
'callback' => 'slickgrid_return_commands_from_form',
),
),
'do' => array(
'#type' => 'submit',
'#value' => t('Undo'),
'#ajax' => array(
'callback' => 'slickgrid_return_commands_from_form',
),
),
),
);
}