[drupal-devel] New themeable function for buttons?
Robert Douglass
rob at robshouse.net
Thu Jul 7 04:55:50 UTC 2005
The Cancel link next to the button is wrong, imo. I don't like it.
Cancel is an action even if it doesn't cause something in the database
to be updated. In fact, it does update the db - as does every click on
every link. Therefore we need to look at it from the user's perspective.
Cancel is an action. It should be a button. Cancelling a process is most
definitely different than navigating to the homepage. "Home" should be a
link, Cancel, Submit, Delete, Confirm, Contact, Reply, Vote etc are all
actions and should be buttons.
I think the confirm link next to the button is ugly too and I think
making the delete button a link would be a big step backwards in user
friendliness.
Making the cancel button into a link was a mistake and I'd like to see
it undone. Cancel is an action. It is a verb. Don't expect the user to
understand that the Delete button only called up a form which enables
them to delete if they press delete again. From their point of view,
they took an action by saying Delete in the first place. The
confirmation screen should have Confirm and Cancel (both buttons). After
all, the user already took the action of initiating a Delete - why
should the Delete button appear twice? That's another issue, though.
-Robert
neil at civicspacelabs.org wrote:
> 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