Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug: View HTML Table class displays tag attributes as columns #8361

Closed
eSkiSo opened this issue Dec 22, 2023 · 5 comments
Closed

Bug: View HTML Table class displays tag attributes as columns #8361

eSkiSo opened this issue Dec 22, 2023 · 5 comments
Labels
wontfix Current code behavior being reported or fixed is intentional and won't be changed

Comments

@eSkiSo
Copy link
Contributor

eSkiSo commented Dec 22, 2023

PHP Version

8.2

CodeIgniter4 Version

4.4.3

CodeIgniter4 Installation Method

Composer (using codeigniter4/appstarter)

Which operating systems have you tested for this bug?

Linux

Which server did you use?

apache

Database

MySQL 8

What happened?

When using the addRow using 'data'with cell tag attributes (class, colspan, etc), the cell tags attributes will be displayed as columns

Steps to Reproduce

$table = new \CodeIgniter\View\Table();
$table->addRow(['data' => 'Blue', 'class' => 'highlight', 'colspan' => 2]);
echo $table->generate();

Expected Output

Expected:

<td class='highlight' colspan='2'>Blue</td>

What it outputs:

<td>Blue</td><td>highlight</td><td>2</td></tr>

Anything else?

Please notice that if you add another 'column' on the same addRow it will output correctly:

$table->addRow(['data' => 'Blue', 'class' => 'highlight', 'colspan' => 2], 'Red');

Outputs:

<td colspan="2" class="highlight">Blue</td><td>Red</td></tr>
@eSkiSo eSkiSo added the bug Verified issues on the current code behavior or pull requests that will fix them label Dec 22, 2023
@kenjis
Copy link
Member

kenjis commented Dec 22, 2023

Related #8054

@kenjis
Copy link
Member

kenjis commented Dec 22, 2023

I have confirmed this behavior.
But do you really need to output one column table like that?

@kenjis
Copy link
Member

kenjis commented Dec 22, 2023

This seems difficult (impossible?) to fix. So I don't fix.

@kenjis kenjis removed the bug Verified issues on the current code behavior or pull requests that will fix them label Dec 23, 2023
@kenjis
Copy link
Member

kenjis commented Dec 23, 2023

This is not a bug. Because you pass three elements to addRow().
The following two lines are the same meaning, passing three column data.

$table->addRow('Blue', 'Red', 'Green');
$table->addRow(['Blue', 'Red', 'Green']);

If you need to pass one element, use array of array.

        $table = new \CodeIgniter\View\Table();
        $table->addRow([['data' => 'Blue', 'class' => 'highlight', 'colspan' => 2]]);
        return $table->generate();

@kenjis kenjis added the wontfix Current code behavior being reported or fixed is intentional and won't be changed label Dec 23, 2023
@eSkiSo
Copy link
Contributor Author

eSkiSo commented Dec 24, 2023

Fair enough. Close it.

@eSkiSo eSkiSo closed this as completed Dec 24, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
wontfix Current code behavior being reported or fixed is intentional and won't be changed
Projects
None yet
Development

No branches or pull requests

2 participants