function _option_nfs_cancel in Node and Comments Form Settings 7.2
Same name and namespace in other branches
- 6.3 includes/option_nfs_cancel.inc \_option_nfs_cancel()
- 6.2 includes/option_nfs_cancel.inc \_option_nfs_cancel()
- 7.3 includes/option_nfs_cancel.inc \_option_nfs_cancel()
Change the value for the submit button.
There's no if here.
File
- includes/
option_nfs_cancel.inc, line 8
Code
function _option_nfs_cancel(&$form, &$form_state, $settings, $node) {
// Cancel is Enabled.
// Some behaviour is set.
if ($settings['nfs_cancel']['nfs_cancel_status'] == 0 && isset($settings['nfs_cancel']['nfs_cancel_behaviour'])) {
switch ($settings['nfs_cancel']['nfs_cancel_behaviour']) {
case 0:
// Javascript case.
$form['actions']['cancel'] = array(
'#markup' => '<a class="form-button form-btn form-button-cancel" rel="nofollow" href="javascript: history.go(-1)" title="Cancel" alt="Cancel">' . t('Cancel') . '</a>',
'#weight' => 51,
);
break;
case 1:
// Drupal destination case
// Patch from http://drupal.org/node/116939
// Thanks to rkerr http://drupal.org/user/20129 and quicksketch (http://drupal.org/user/35821)
// Generate a URL for the cancel link.
if (!isset($_GET['destination']) || $_GET['destination'] == $_GET['q']) {
$url['path'] = !empty($node->nid) ? 'node/' . $node->nid : '<front>';
}
else {
// Parse url to split it up to its components.
$url = parse_url($_GET['destination']);
}
$form['actions']['cancel'] = array(
'#markup' => l(t('Cancel'), $url['path'], array(
'query' => isset($url['query']) ? $url['query'] : '',
'fragment' => isset($url['fragment']) ? $url['fragment'] : '',
'attributes' => array(
'class' => 'form-button form-button-cancel',
'rel' => 'nofollow',
),
)),
'#weight' => 51,
);
break;
}
}
return $form;
}