[drupal-devel] New themeable function for buttons?
neil at civicspacelabs.org
neil at civicspacelabs.org
Wed Jul 6 23:31:05 UTC 2005
The theme_confirm() function contains the following code:
<?php
$output .= '<div class="container-inline">';
$output .= form_submit($yes ? $yes : t('Confirm'));
$output .= l($no ? $no : t('Cancel'), $path);
$output .= "</div>\n";
?>
The use of HTML links, such as 'Cancel,' along side form_submit() will
be more common in the future. I am planning on changing all the Delete
buttons, which should go to a confirmation page, to links. I don't think
that this has been fully documented, but I think it is an accepted de
facto standard now. The main rule of thumb is that links should never
change anything.
I think a themeable button wrapper function is needed. The above code
could be:
<?php
$buttons = array();
$buttons[] = form_submit($yes ? $yes : t('Confirm'));
$buttons[] = l($no ? $no : t('Cancel'), $path);
$output .= theme('buttons', $buttons);
?>
<?php
theme_buttons($buttons = array()) {
return '<div class="container-inline">'. implode('', $buttons) .'</div>';
}
?>
I have two specific questions for the list:
1. Does this look like a good idea? Does anything need to be changed for
better themeability?
2. Does this interfere with any other possible changes to form output?
-Neil
More information about the drupal-devel
mailing list