Skip to content

Commit 4ffc352

Browse files
committed
Fix checked status on page load
1 parent 357dbd8 commit 4ffc352

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

src/templates/Packet/Edit.phtml

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -87,21 +87,21 @@ require('./header.inc.phtml');
8787
<table>
8888
<thead></thead><tbody>
8989
<?php function add_product_checkbox( $id, $name, $checked ) { ?>
90-
<td><input type="checkbox" id="<?php echo $id; ?>" name="used_by[]" value="<?php echo $id; ?>"<?php if ( $checked ) { ?> checked="checked"<?php } ?>/><label for="<?php echo $id; ?>"><?php echo $name; ?></label></td>
90+
<td><input type="checkbox" id="used_by_<?php echo $id; ?>" name="used_by[]" value="<?php echo $id; ?>"<?php if ( $checked ) { ?> checked="checked"<?php } ?>/><label for="used_by_<?php echo $id; ?>"><?php echo $name; ?></label></td>
9191
<?php }
9292
$product_ubound = count( $this->getContext()->products );
93-
for ( $product_i = 0; $product_i < $product_ubound; ++$product_i ) {
94-
$p = $this->getContext()->products[ $product_i ];
95-
?>
93+
for ( $product_i = 0; $product_i < $product_ubound; ++$product_i ) { ?>
9694
<tr>
9795
<?php
98-
$checked = isset( $this->getContext()->used_by[ $p->getBnetProductId() ]);
96+
$p = $this->getContext()->products[ $product_i ];
97+
$checked = in_array( $p, $this->getContext()->used_by );
9998
add_product_checkbox( $p->getBnetProductId(), $p->getLabel(), $checked );
10099
if ( $product_i + 1 < $product_ubound ) {
101100
$p = $this->getContext()->products[ ++$product_i ];
102-
$checked = isset( $this->getContext()->used_by[ $p->getBnetProductId() ]);
101+
$checked = in_array( $p, $this->getContext()->used_by );
103102
add_product_checkbox( $p->getBnetProductId(), $p->getLabel(), $checked );
104-
} ?>
103+
}
104+
?>
105105
</tr>
106106
<?php } ?>
107107
</tbody>

0 commit comments

Comments
 (0)