How to render simple redirect button

5 views
Skip to first unread message

kenorb

unread,
Dec 2, 2010, 8:13:31 AM12/2/10
to drupal-hackers
Href method:
$button = array('#type' => 'button', '#value' => t('My button'));
print l(drupal_render($button), 'my_path', array('html' => TRUE));


Javascript method:
$form['cancel'] = array(
‘#type’ => ‘button’,
‘#attributes’ => array(‘onClick’ => ‘location.replace(“‘.
referer_uri() .’”); return false;’),
‘#value’ => t(‘Cancel’),
);

Drupal 7.x version:
array('#type' => 'submit', '#redirect' => 'foo/bar')
See: http://drupal.org/node/736564

Drupal 6.x normal way:
$form['submit'] = array('#type' => 'submit', '#value' => t('Import'),
'#submit' => array('my_function'));
See: http://api.drupal.org/api/drupal/developer--topics--forms_api_reference.html/6#submit

References:
http://drupal.org/node/987066
http://www.lacisoft.com/blog/2009/10/05/how-to-add-a-cancel-button-to-drupal-forms/

kenorb

unread,
Dec 2, 2010, 8:37:13 AM12/2/10
to drupal-hackers
Server-side inline version:

$button = array('#type' => 'form', 'my_button' => array('#type' =>
'submit', '#value' => 'My alerts', '#submit' => array('drupal_goto' =>
array('my_path'))));
$output .= drupal_render($button);

Needs some work, because doesn't work;/

Reply all
Reply to author
Forward
0 new messages