Change button rows to use one form and table per row

This commit is contained in:
Ilia Ross
2026-10-02 05:26:15 +02:00
parent 359eb13f0e
commit 875c973658
2 changed files with 22 additions and 16 deletions

View File

@@ -613,7 +613,14 @@ tr.ui_buttons_row > td {
border-top: 1px solid var(--border-color-lighter);
vertical-align: middle;
}
tr.ui_buttons_row:first-child > td { border-top: 0; }
/* Each row is a form with a table of its own, as a form cannot wrap table
* rows. Flattening the wrappers lets all rows share the outer columns */
tr.ui_buttons_form_row,
tr.ui_buttons_form_row > td,
form.ui_buttons_form,
form.ui_buttons_form > table,
form.ui_buttons_form > table > tbody { display: contents; }
tr.ui_buttons_form_row:first-child tr.ui_buttons_row > td { border-top: 0; }
td.ui_buttons_label {
width: 1%;
padding-right: 16px;

View File

@@ -1,7 +1,7 @@
use vars qw($theme_no_table $ui_radio_selector_donejs $module_name
$ui_multi_select_donejs, $ui_formcount,
$ui_form_end_side_by_side_donecss,
$ui_form_grouped_buttons_donecss, $ui_buttons_formcount);
$ui_form_grouped_buttons_donecss);
=head1 ui-lib.pl
@@ -1856,7 +1856,7 @@ inputs. The parameters are :
=item button-label - Text to appear on the button.
=item description - Text to appear next to the button, describing in more detail what it does. Inputs in it are linked to the button's form by the HTML5 C<form> attribute.
=item description - Text to appear next to the button, describing in more detail what it does.
=item hiddens - HTML for hidden fields to include in the form this function generates.
@@ -1881,26 +1881,25 @@ if (ref($hiddens)) {
$hiddens = join("\n", map { &ui_hidden(@$_) } @$hiddens);
}
# A form cannot wrap table rows, so it lives in the button cell. Inputs in
# the description cell are linked to it by the HTML5 form attribute
my $formid;
if (!$singlecell && $desc =~ /<(input|select|textarea|button)\b/i) {
$formid = "ui_buttons_form_".(++$ui_buttons_formcount);
$desc =~ s/<(input|select|textarea|button)\b(?![^>]*\sform\s*=)/<$1 form='$formid'/gi;
}
return "<tr class='ui_buttons_row".($disabled ? " disabled" : "")."'> ".
# A form cannot wrap table rows, so each row is a full-width cell holding
# the form, which wraps a table of its own
return "<tr class='ui_buttons_form_row'><td colspan='2' style='padding:0'>\n".
"<form action='$script' class='ui_buttons_form' method='$postmethod'>\n".
$hiddens.
"<table width='100%' cellspacing='0'>\n".
"<tr class='ui_buttons_row".($disabled ? " disabled" : "")."'> ".
"<td nowrap".($singlecell ? " colspan='2'" : " width='20%'").
" valign='top' class='ui_buttons_label'>".
"<form action='$script' class='ui_buttons_form'".
($formid ? " id='$formid'" : "")." method='$postmethod'>\n".
$hiddens.
($before ? $before." " : "").
&ui_submit($label, '', $disabled).
($after ? " ".$after : "")."</form></td>\n".
($after ? " ".$after : "")."</td>\n".
($singlecell ? "" :
"<td width='80%' valign='top' class='ui_buttons_value'>".
$desc."</td>\n").
"</tr>\n";
"</tr>\n".
"</table>\n".
"</form>\n".
"</td></tr>\n";
}
=head2 ui_buttons_hr([title])